Class UnmodifiableMultiSet<E>
- Type Parameters:
- E- the type held in the multiset
- All Implemented Interfaces:
- Serializable,- Iterable<E>,- Collection<E>,- MultiSet<E>,- Unmodifiable
MultiSet to ensure it can't be altered.
 Attempts to modify it will result in an UnsupportedOperationException.
- Since:
- 4.1
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.apache.commons.collections4.MultiSetMultiSet.Entry<E>
- 
Method SummaryModifier and TypeMethodDescriptionbooleanAdds one copy of the specified object to the MultiSet.intAdds a number of occurrences of the specified object to the MultiSet.booleanaddAll(Collection<? extends E> coll) voidclear()entrySet()Returns aSetof all entries contained in the MultiSet.iterator()Returns anIteratorover the entire set of members, including copies due to cardinality.booleanRemoves one occurrence of the given object from the MultiSet.intRemoves a number of occurrences of the specified object from the MultiSet.booleanremoveAll(Collection<?> coll) Remove all occurrences of all elements from this MultiSet represented in the given collection.booleanbooleanretainAll(Collection<?> coll) Remove any elements of this MultiSet that are not contained in the given collection.intSets the number of occurrences of the specified object in the MultiSet to the given count.Returns aSetof unique elements in the MultiSet.static <E> MultiSet<E> unmodifiableMultiSet(MultiSet<? extends E> multiset) Factory method to create an unmodifiable multiset.Methods inherited from class org.apache.commons.collections4.multiset.AbstractMultiSetDecoratordecorated, equals, getCount, hashCodeMethods inherited from class org.apache.commons.collections4.collection.AbstractCollectionDecoratorcontains, containsAll, isEmpty, setCollection, size, toArray, toArray, toStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collectioncontains, isEmpty, parallelStream, spliterator, stream, toArray, toArrayMethods inherited from interface org.apache.commons.collections4.MultiSetcontainsAll, size
- 
Method Details- 
unmodifiableMultiSetFactory method to create an unmodifiable multiset.If the multiset passed in is already unmodifiable, it is returned. - Type Parameters:
- E- the type of the elements in the multiset
- Parameters:
- multiset- the multiset to decorate, may not be null
- Returns:
- an unmodifiable MultiSet
- Throws:
- NullPointerException- if multiset is null
 
- 
addDescription copied from interface:MultiSetAdds one copy of the specified object to the MultiSet.If the object is already in the MultiSet.uniqueSet()then increment its count as reported byMultiSet.getCount(Object). Otherwise, add it to theMultiSet.uniqueSet()and report its count as 1.- Specified by:
- addin interface- Collection<E>
- Specified by:
- addin interface- MultiSet<E>
- Overrides:
- addin class- AbstractCollectionDecorator<E>
- Parameters:
- object- the object to add
- Returns:
- truealways, as the size of the MultiSet is increased in any case
 
- 
addDescription copied from interface:MultiSetAdds a number of occurrences of the specified object to the MultiSet.If the object is already in the MultiSet.uniqueSet()then increment its count as reported byMultiSet.getCount(Object). Otherwise, add it to theMultiSet.uniqueSet()and report its count asoccurrences.- Specified by:
- addin interface- MultiSet<E>
- Overrides:
- addin class- AbstractMultiSetDecorator<E>
- Parameters:
- 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
- Returns:
- the number of occurrences of the object in the multiset before this operation; possibly zero
 
- 
addAll- Specified by:
- addAllin interface- Collection<E>
- Overrides:
- addAllin class- AbstractCollectionDecorator<E>
 
- 
clear- Specified by:
- clearin interface- Collection<E>
- Overrides:
- clearin class- AbstractCollectionDecorator<E>
 
- 
entrySet
- 
iterator
- 
removeDescription copied from interface:MultiSetRemoves one occurrence of the given object from the MultiSet.If the number of occurrences after this operation is reduced to zero, the object will be removed from the MultiSet.uniqueSet().- Specified by:
- removein interface- Collection<E>
- Specified by:
- removein interface- MultiSet<E>
- Overrides:
- removein class- AbstractCollectionDecorator<E>
- Parameters:
- object- the object to remove
- Returns:
- trueif this call changed the collection
 
- 
removeDescription copied from interface:MultiSetRemoves a number of occurrences of the specified object from the 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. - Specified by:
- removein interface- MultiSet<E>
- Overrides:
- removein class- AbstractMultiSetDecorator<E>
- Parameters:
- 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
- Returns:
- the number of occurrences of the object in the multiset before the operation; possibly zero
 
- 
removeAllDescription copied from interface:MultiSetRemove all occurrences of all elements from this MultiSet represented in the given collection.- Specified by:
- removeAllin interface- Collection<E>
- Specified by:
- removeAllin interface- MultiSet<E>
- Overrides:
- removeAllin class- AbstractCollectionDecorator<E>
- Parameters:
- coll- the collection of elements to remove
- Returns:
- trueif this call changed the multiset
 
- 
removeIf- Specified by:
- removeIfin interface- Collection<E>
- Overrides:
- removeIfin class- AbstractCollectionDecorator<E>
- Since:
- 4.4
 
- 
retainAllDescription copied from interface:MultiSetRemove any elements of this MultiSet that are not contained in the given collection.- Specified by:
- retainAllin interface- Collection<E>
- Specified by:
- retainAllin interface- MultiSet<E>
- Overrides:
- retainAllin class- AbstractCollectionDecorator<E>
- Parameters:
- coll- the collection of elements to retain
- Returns:
- trueif this call changed the multiset
 
- 
setCountDescription copied from interface:MultiSetSets the number of occurrences of the specified object in the MultiSet to the given count.If the provided count is zero, the object will be removed from the MultiSet.uniqueSet().- Specified by:
- setCountin interface- MultiSet<E>
- Overrides:
- setCountin class- AbstractMultiSetDecorator<E>
- Parameters:
- object- the object to update
- count- the number of occurrences of the object
- Returns:
- the number of occurrences of the object before this operation, zero if the object was not contained in the multiset
 
- 
uniqueSetDescription copied from interface:MultiSetReturns aSetof 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. 
 
-