private static final class Multisets.FilteredMultiset<E> extends AbstractMultiset<E>
AbstractMultiset.ElementSet, AbstractMultiset.EntrySetMultiset.Entry<E>| Modifier and Type | Field and Description |
|---|---|
(package private) Predicate<? super E> |
predicate |
(package private) Multiset<E> |
unfiltered |
| Constructor and Description |
|---|
FilteredMultiset(Multiset<E> unfiltered,
Predicate<? super E> predicate) |
| Modifier and Type | Method and Description |
|---|---|
int |
add(E element,
int occurrences)
Adds a number of occurrences of an element to this multiset.
|
void |
clear() |
int |
count(java.lang.Object element)
Returns the number of occurrences of an element in this multiset (the
count of the element).
|
(package private) java.util.Set<E> |
createElementSet()
Creates a new instance of this multiset's element set, which will be
returned by
AbstractMultiset.elementSet(). |
(package private) java.util.Set<Multiset.Entry<E>> |
createEntrySet() |
(package private) int |
distinctElements() |
(package private) java.util.Iterator<Multiset.Entry<E>> |
entryIterator() |
UnmodifiableIterator<E> |
iterator() |
int |
remove(java.lang.Object element,
int occurrences)
Removes a number of occurrences of the specified element from this
multiset.
|
add, addAll, contains, elementSet, entrySet, equals, hashCode, isEmpty, remove, removeAll, retainAll, setCount, setCount, size, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcontainsAllpublic UnmodifiableIterator<E> iterator()
MultisetElements that occur multiple times in the multiset will appear multiple times in this iterator, though not necessarily sequentially.
java.util.Set<E> createElementSet()
AbstractMultisetAbstractMultiset.elementSet().createElementSet in class AbstractMultiset<E>java.util.Set<Multiset.Entry<E>> createEntrySet()
createEntrySet in class AbstractMultiset<E>java.util.Iterator<Multiset.Entry<E>> entryIterator()
entryIterator in class AbstractMultiset<E>int distinctElements()
distinctElements in class AbstractMultiset<E>public int count(@Nullable
java.lang.Object element)
MultisetObject.equals(java.lang.Object)-based
multiset, this gives the same result as Collections.frequency(java.util.Collection<?>, java.lang.Object)
(which would presumably perform more poorly).
Note: the utility method Iterables.frequency(java.lang.Iterable<?>, java.lang.Object) generalizes
this operation; it correctly delegates to this method when dealing with a
multiset, but it can also accept any other iterable type.
public int add(@Nullable
E element,
int occurrences)
Multisetoccurrences == 1, this method has the identical effect to Multiset.add(Object). This method is functionally equivalent (except in the case
of overflow) to the call addAll(Collections.nCopies(element,
occurrences)), which would presumably perform much more poorly.add in interface Multiset<E>add in class AbstractMultiset<E>element - the element to add occurrences of; may be null only if
explicitly allowed by the implementationoccurrences - the number of occurrences of the element to add. May be
zero, in which case no change will be made.public int remove(@Nullable
java.lang.Object element,
int occurrences)
Multisetoccurrences == 1, this is functionally equivalent to the call
remove(element).remove in interface Multiset<E>remove in class AbstractMultiset<E>element - the element to conditionally remove occurrences ofoccurrences - the number of occurrences of the element to remove. May
be zero, in which case no change will be made.public void clear()
clear in interface java.util.Collection<E>clear in class AbstractMultiset<E>