static class Multimaps.Keys<K,V> extends AbstractMultiset<K>
AbstractMultiset.ElementSet, AbstractMultiset.EntrySetMultiset.Entry<E>| Modifier and Type | Field and Description |
|---|---|
(package private) Multimap<K,V> |
multimap |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
contains(java.lang.Object element)
Determines whether this multiset contains the specified element.
|
int |
count(java.lang.Object element)
Returns the number of occurrences of an element in this multiset (the count of the
element).
|
(package private) int |
distinctElements() |
(package private) java.util.Iterator<K> |
elementIterator() |
java.util.Set<K> |
elementSet()
Returns the set of distinct elements contained in this multiset.
|
(package private) java.util.Iterator<Multiset.Entry<K>> |
entryIterator() |
void |
forEach(java.util.function.Consumer<? super K> consumer) |
java.util.Iterator<K> |
iterator() |
int |
remove(java.lang.Object element,
int occurrences)
Removes a number of occurrences of the specified element from this multiset.
|
int |
size()
Returns the total number of all occurrences of all elements in this multiset.
|
java.util.Spliterator<K> |
spliterator() |
add, add, addAll, createElementSet, createEntrySet, entrySet, equals, hashCode, isEmpty, remove, removeAll, retainAll, setCount, setCount, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcontainsAll, forEachEntryjava.util.Iterator<Multiset.Entry<K>> entryIterator()
entryIterator in class AbstractMultiset<K>public java.util.Spliterator<K> spliterator()
public void forEach(java.util.function.Consumer<? super K> consumer)
MultisetElements that occur multiple times in the multiset will be passed to the Consumer
correspondingly many times, though not necessarily sequentially.
int distinctElements()
distinctElements in class AbstractMultiset<K>public int size()
MultisetNote: this method does not return the number of distinct elements in the
multiset, which is given by entrySet().size().
public boolean contains(@CheckForNull
java.lang.Object element)
MultisetThis method refines Collection.contains(java.lang.Object) to further specify that it may not
throw an exception in response to element being null or of the wrong type.
public java.util.Iterator<K> iterator()
MultisetElements that occur multiple times in the multiset will appear multiple times in this iterator, though not necessarily sequentially.
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 remove(@CheckForNull
java.lang.Object element,
int occurrences)
Multisetoccurrences == 1, this is functionally equivalent to the call remove(element).remove in interface Multiset<K>remove in class AbstractMultiset<K>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<K>clear in class AbstractMultiset<K>public java.util.Set<K> elementSet()
MultisetIf the element set supports any removal operations, these necessarily cause all occurrences of the removed element(s) to be removed from the multiset. Implementations are not expected to support the add operations, although this is possible.
A common use for the element set is to find the number of distinct elements in the multiset:
elementSet().size().
elementSet in interface Multiset<K>elementSet in class AbstractMultiset<K>java.util.Iterator<K> elementIterator()
elementIterator in class AbstractMultiset<K>