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.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add one element once to this set.boolean
Add one element multiple times to this set.void
clear()
Remove all objects from this instance.boolean
Remove the given element once from this set.boolean
removeAll
(Collection<? extends A> c) Remove all elements in the given collection completely from this set.boolean
removeAllUnchecked
(Collection<?> c) Remove all elements in the given collection completely from this set.boolean
removeDomain
(A a) Remove the given element completely from this set.boolean
Remove the given element completely from this set.boolean
Remove the given element once from this set.boolean
retainAll
(Collection<? extends A> c) Remove all elements not contained in the given collection completely from this set.boolean
retainAllUnchecked
(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, wait
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface eu.bandm.tools.util.multi.Multiset
addAll, contains, containsUnchecked, count, countAll, countAllUnchecked, countUnchecked, domain, isEmpty, supportMap
-
Constructor Details
-
UnmodifiableMultiset
public UnmodifiableMultiset()Only constructor
-
-
Method Details
-
clear
public void clear()Remove all objects from this instance.- Specified by:
clear
in 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:
add
in 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:
add
in 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:
remove
in 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:
removeUnchecked
in 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:
removeDomain
in 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:
removeDomainUnchecked
in 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:
removeAll
in 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:
removeAllUnchecked
in 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:
retainAll
in 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:
retainAllUnchecked
in interfaceMultiset<A>
- Parameters:
c
- collection of all elements not to remove- Returns:
- whether this instance has changed
- Throws:
UnsupportedOperationException
- always
-