E
- the type held in the multisetpublic 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(java.util.Collection<? extends E> coll) |
void |
clear() |
java.util.Set<MultiSet.Entry<E>> |
entrySet()
Returns a
Set of all entries contained in the MultiSet. |
java.util.Iterator<E> |
iterator()
Returns an
Iterator over the entire set of members,
including copies due to cardinality. |
boolean |
remove(java.lang.Object object)
Removes one occurrence of the given object from the MultiSet.
|
int |
remove(java.lang.Object object,
int count)
Removes a number of occurrences of the specified object from the MultiSet.
|
boolean |
removeAll(java.util.Collection<?> coll)
Remove all occurrences of all elements from this MultiSet represented
in the given collection.
|
boolean |
retainAll(java.util.Collection<?> coll)
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.
|
java.util.Set<E> |
uniqueSet()
Returns a
Set of unique elements in the MultiSet. |
static <E> MultiSet<E> |
unmodifiableMultiSet(MultiSet<? extends E> multiset)
Factory method to create an unmodifiable multiset.
|
equals, getCount, hashCode
contains, containsAll, isEmpty, size, toArray, toArray, toString
containsAll, size
public 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 multisetmultiset
- the multiset to decorate, may not be nulljava.lang.NullPointerException
- if multiset is nullpublic java.util.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.uniqueSet()
then increment its
count as reported by MultiSet.getCount(Object)
. Otherwise add it to the
MultiSet.uniqueSet()
and report its count as 1.
public boolean addAll(java.util.Collection<? extends E> coll)
addAll
in interface java.util.Collection<E>
addAll
in class AbstractCollectionDecorator<E>
public void clear()
clear
in interface java.util.Collection<E>
clear
in class AbstractCollectionDecorator<E>
public boolean remove(java.lang.Object object)
MultiSet
If the number of occurrences after this operations is reduced
to zero, the object will be removed from the MultiSet.uniqueSet()
.
public boolean removeAll(java.util.Collection<?> coll)
MultiSet
public boolean retainAll(java.util.Collection<?> coll)
MultiSet
public int setCount(E object, int count)
MultiSet
If the provided count is zero, the object will be removed from the
MultiSet.uniqueSet()
.
setCount
in interface MultiSet<E>
setCount
in class AbstractMultiSetDecorator<E>
object
- the object to updatecount
- the number of occurrences of the objectpublic int add(E object, int count)
MultiSet
If the object is already in the MultiSet.uniqueSet()
then increment its
count as reported by MultiSet.getCount(Object)
. Otherwise add it to the
MultiSet.uniqueSet()
and report its count as occurrences
.
add
in interface MultiSet<E>
add
in class AbstractMultiSetDecorator<E>
object
- the object to addcount
- the number of occurrences to add, may be zero,
in which case no change is made to the multisetpublic int remove(java.lang.Object object, 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 removecount
- the number of occurrences to remove, may be zero,
in which case no change is made to the multisetpublic java.util.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 java.util.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.
Copyright © 2010 - 2020 Adobe. All Rights Reserved