Package eu.bandm.tools.util.multi
Class UnmodifiableMultiset<A>
java.lang.Object
eu.bandm.tools.util.multi.UnmodifiableMultiset<A>
- Type Parameters:
A- type of the contained elements
- All Implemented Interfaces:
Multiset<A>,Serializable,Iterable<A>
A wrapper to protect the contents of an instance of a multiset.
Not to be called by the user, but by the factory methods in
Multisets.
To create such a wrapper, use Multisets.unmodifiableMultiset(eu.bandm.tools.util.multi.Multiset<A>).
All methods which try to change the state of this instance
throw an UnsupportedOperationException.-
Field Summary
Fields inherited from interface eu.bandm.tools.util.multi.Multiset
DEFAULT_MULTI_FORMAT_STRING, DEFAULT_SINGLE_FORMAT_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd one element once to this set.booleanAdd one element multiple times to this set.voidclear()Remove all objects from this instance.booleanRemove the given element once from this set.booleanremoveAll(Collection<? extends A> c) Remove all elements in the given collection completely from this set.booleanremoveAllUnchecked(Collection<?> c) Remove all elements in the given collection completely from this set.booleanremoveDomain(A a) Remove the given element completely from this set.booleanRemove the given element completely from this set.booleanRemove the given element once from this set.booleanretainAll(Collection<? extends A> c) Remove all elements not contained in the given collection completely from this set.booleanretainAllUnchecked(Collection<?> c) Remove all elements not contained in the given collection completely from this set.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface eu.bandm.tools.util.multi.Multiset
addAll, contains, containsUnchecked, count, countAll, countAllUnchecked, countUnchecked, domain, isEmpty, supportMap, toString, toString
-
Constructor Details
-
UnmodifiableMultiset
public UnmodifiableMultiset()Only constructor
-
-
Method Details
-
clear
public void clear()Remove all objects from this instance.- Specified by:
clearin interfaceMultiset<A>- Throws:
UnsupportedOperationException- always
-
add
Add one element once to this set. This means to increase the number of contained elements by one.- Specified by:
addin interfaceMultiset<A>- Parameters:
a- element to add.- Returns:
- whether the Multiset has been changed.
Is defined only for a better analogy to the philosophy of
java.util.Collection,
but indeed returns always
true. - Throws:
UnsupportedOperationException- always
-
add
Add one element multiple times to this set. This means to increase the number of contained elements by the given mulitplicity.- Specified by:
addin interfaceMultiset<A>- Parameters:
a- element to add.i- number of additions. Must be greater or equal to zero.- Returns:
- whether the Multiset has been changed. This is the case when i is greater zero.
- Throws:
UnsupportedOperationException- always
-
remove
Remove the given element once from this set. That means, decrement the number of its containments if and only if it is greater than zero.- Specified by:
removein interfaceMultiset<A>- Parameters:
a- element to remove.- Returns:
- whether this instance has changed.
- Throws:
UnsupportedOperationException- always
-
removeUnchecked
Remove the given element once from this set. That means, decrement the number of its containments iff it is greater zero.- Specified by:
removeUncheckedin interfaceMultiset<A>- Parameters:
a- element to remove.- Returns:
- whether this instance has changed.
- Throws:
UnsupportedOperationException- always
-
removeDomain
Remove the given element completely from this set.- Specified by:
removeDomainin interfaceMultiset<A>- Parameters:
a- element to remove.- Returns:
- whether this instance has changed.
- Throws:
UnsupportedOperationException- always
-
removeDomainUnchecked
Remove the given element completely from this set.- Specified by:
removeDomainUncheckedin interfaceMultiset<A>- Parameters:
a- element to remove.- Returns:
- whether this instance has changed.
- Throws:
UnsupportedOperationException- always
-
removeAll
Remove all elements in the given collection completely from this set.- Specified by:
removeAllin interfaceMultiset<A>- Parameters:
c- collection of all elements to remove- Returns:
- whether this instance has changed
- Throws:
UnsupportedOperationException- always
-
removeAllUnchecked
Remove all elements in the given collection completely from this set.- Specified by:
removeAllUncheckedin interfaceMultiset<A>- Parameters:
c- collection of all elements to remove- Returns:
- whether this instance has changed
- Throws:
UnsupportedOperationException- always
-
retainAll
Remove all elements not contained in the given collection completely from this set.- Specified by:
retainAllin interfaceMultiset<A>- Parameters:
c- collection of all elements not to remove- Returns:
- whether this instance has changed
- Throws:
UnsupportedOperationException- always
-
retainAllUnchecked
Remove all elements not contained in the given collection completely from this set.- Specified by:
retainAllUncheckedin interfaceMultiset<A>- Parameters:
c- collection of all elements not to remove- Returns:
- whether this instance has changed
- Throws:
UnsupportedOperationException- always
-