static class Multimaps.Keys<K,V> extends AbstractMultiset<K>
Modifier and Type | Class and Description |
---|---|
(package private) class |
Multimaps.Keys.KeysEntrySet |
AbstractMultiset.ElementSet, AbstractMultiset.EntrySet
Multiset.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) java.util.Set<Multiset.Entry<K>> |
createEntrySet() |
(package private) int |
distinctElements() |
java.util.Set<K> |
elementSet()
Returns the set of distinct elements contained in this multiset.
|
(package private) java.util.Iterator<Multiset.Entry<K>> |
entryIterator() |
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.
|
add, add, addAll, createElementSet, entrySet, equals, hashCode, isEmpty, remove, removeAll, retainAll, setCount, setCount, size, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
containsAll
java.util.Iterator<Multiset.Entry<K>> entryIterator()
entryIterator
in class AbstractMultiset<K>
int distinctElements()
distinctElements
in class AbstractMultiset<K>
java.util.Set<Multiset.Entry<K>> createEntrySet()
createEntrySet
in class AbstractMultiset<K>
public boolean contains(@Nullable java.lang.Object element)
Multiset
This 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()
Multiset
Elements that occur multiple times in the multiset will appear multiple times in this iterator, though not necessarily sequentially.
public int count(@Nullable java.lang.Object element)
Multiset
Object.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 remove(@Nullable java.lang.Object element, int occurrences)
Multiset
occurrences == 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()
Multiset
If 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>