public final class UnmodifiableMultiSet<E> extends AbstractMultiSetDecorator<E> implements Unmodifiable
MultiSet to ensure it can't be altered.
Attempts to modify it will result in an UnsupportedOperationException.
MultiSet.Entry <E> | Modifier and Type | Method and Description |
|---|---|
boolean |
add(E object)
Adds one copy of the specified object to the MultiSet.
|
int |
add(E object, int count)
Adds a number of occurrences of the specified object to the MultiSet.
|
boolean |
addAll(Collection
|
void |
clear()
|
Set |
entrySet()
Returns a
Set of all entries contained in the MultiSet.
|
Iterator |
iterator()
Returns an
Iterator over the entire set of members, including copies due to cardinality.
|
boolean |
remove(Object
Removes one occurrence of the given object from the MultiSet.
|
int |
remove(Object
Removes a number of occurrences of the specified object from the MultiSet.
|
boolean |
removeAll(Collection
Remove all occurrences of all elements from this MultiSet represented in the given collection.
|
boolean |
retainAll(Collection
Remove any elements of this MultiSet that are not contained in the given collection.
|
int |
setCount(E object, int count)
Sets the number of occurrences of the specified object in the MultiSet to the given count.
|
Set |
uniqueSet()
Returns a
Set of unique elements in the MultiSet.
|
static <E> MultiSet |
unmodifiableMultiSet(MultiSet
Factory method to create an unmodifiable multiset.
|
decorated, equals, getCount, hashCodecontains, containsAll, isEmpty, setCollection, size, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcontainsAll, sizecontains, isEmpty, parallelStream, removeIf, spliterator, stream, toArray, toArraypublic static <E> MultiSet<E> unmodifiableMultiSet(MultiSet <? extends E> multiset)
If the multiset passed in is already unmodifiable, it is returned.
E - the type of the elements in the multiset
multiset - the multiset to decorate, may not be null
NullPointerException - if multiset is null
public Iterator<E> iterator()
MultiSet
Iterator over the entire set of members, including copies due to cardinality. This iterator is fail-fast and will not tolerate concurrent modifications.
public boolean add(E object)
MultiSet
If the object is already in the MultiSet then increment its count as reported by MultiSet. Otherwise add it to the MultiSet and report its count as 1.
add in interface
Collection<E>
add in interface
MultiSet<E>
add in class
AbstractCollectionDecorator<E>
object - the object to add
true always, as the size of the MultiSet is increased in any case
public boolean addAll(Collection<? extends E> coll)
public void clear()
public boolean remove(Objectobject)
MultiSet
If the number of occurrences after this operations is reduced to zero, the object will be removed from the MultiSet.
remove in interface
Collection<E>
remove in interface
MultiSet<E>
remove in class
AbstractCollectionDecorator<E>
object - the object to remove
true if this call changed the collection
public boolean removeAll(Collection<?> coll)
MultiSet
removeAll in interface
Collection<E>
removeAll in interface
MultiSet<E>
removeAll in class
AbstractCollectionDecorator<E>
coll - the collection of elements to remove
true if this call changed the multiset
public boolean retainAll(Collection<?> coll)
MultiSet
retainAll in interface
Collection<E>
retainAll in interface
MultiSet<E>
retainAll in class
AbstractCollectionDecorator<E>
coll - the collection of elements to retain
true if this call changed the multiset
public int setCount(E object, int count)
MultiSet
If the provided count is zero, the object will be removed from the MultiSet.
setCount in interface
MultiSet<E>
setCount in class
AbstractMultiSetDecorator<E>
object - the object to update
count - the number of occurrences of the object
public int add(E object, int count)
MultiSet
If the object is already in the MultiSet then increment its count as reported by MultiSet. Otherwise add it to the MultiSet and report its count as occurrences.
add in interface
MultiSet<E>
add in class
AbstractMultiSetDecorator<E>
object - the object to add
count - the number of occurrences to add, may be zero, in which case no change is made to the multiset
public int remove(Objectobject, int count)
MultiSet
If the number of occurrences to remove is greater than the actual number of occurrences in the multiset, the object will be removed from the multiset.
remove in interface
MultiSet<E>
remove in class
AbstractMultiSetDecorator<E>
object - the object to remove
count - the number of occurrences to remove, may be zero, in which case no change is made to the multiset
public Set<E> uniqueSet()
MultiSet
Set of unique elements in the MultiSet.
Uniqueness constraints are the same as those in Set.
The returned set is backed by this multiset, so any change to either is immediately reflected in the other. Only removal operations are supported, in which case all occurrences of the element are removed from the backing multiset.
public Set<MultiSet .Entry <E>> entrySet()
MultiSet
Set of all entries contained in the MultiSet.
The returned set is backed by this multiset, so any change to either is immediately reflected in the other.