private static final class Multisets.FilteredMultiset<E> extends Multisets.ViewMultiset<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.
|
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) java.util.Iterator<E> |
elementIterator() |
(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.
|
clear, distinctElements, sizeadd, addAll, contains, elementSet, entrySet, equals, hashCode, isEmpty, remove, removeAll, retainAll, setCount, setCount, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcontainsAll, forEach, forEachEntry, spliteratorpublic 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.Iterator<E> elementIterator()
elementIterator 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>public int count(@CheckForNull
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.
element - the element to count occurrences ofpublic int add(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(@CheckForNull
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.