class ImmutableMultimap.Keys extends ImmutableMultiset<K>
ImmutableMultiset.Builder<E>, ImmutableMultiset.ElementSet<E>, ImmutableMultiset.EntrySetSerializedForm<E>, ImmutableMultiset.SerializedForm
Multiset.Entry<E>
SPLITERATOR_CHARACTERISTICS
Constructor and Description |
---|
Keys() |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.lang.Object object)
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).
|
ImmutableSet<K> |
elementSet()
Returns the set of distinct elements contained in this multiset.
|
(package private) Multiset.Entry<K> |
getEntry(int index) |
(package private) boolean |
isPartialView()
Returns
true if this immutable collection's implementation contains references to
user-created objects that aren't accessible via this collection's methods. |
int |
size()
Returns the total number of all occurrences of all elements in this multiset.
|
(package private) java.lang.Object |
writeReplace() |
add, asList, builder, copyFromEntries, copyIntoArray, copyOf, copyOf, copyOf, entrySet, equals, hashCode, iterator, of, of, of, of, of, of, of, remove, setCount, setCount, toImmutableMultiset, toImmutableMultiset, toString
add, addAll, clear, internalArray, internalArrayEnd, internalArrayStart, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, containsAll, forEach, forEachEntry, remove, removeAll, retainAll, spliterator
public boolean contains(java.lang.Object object)
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 int count(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.
element
- the element to count occurrences ofpublic ImmutableSet<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 ImmutableMultiset<K>
public int size()
Multiset
Note: this method does not return the number of distinct elements in the
multiset, which is given by entrySet().size()
.
Multiset.Entry<K> getEntry(int index)
getEntry
in class ImmutableMultiset<K>
boolean isPartialView()
ImmutableCollection
true
if this immutable collection's implementation contains references to
user-created objects that aren't accessible via this collection's methods. This is generally
used to determine whether copyOf
implementations should make an explicit copy to avoid
memory leaks.isPartialView
in class ImmutableCollection<K>
java.lang.Object writeReplace()
writeReplace
in class ImmutableMultiset<K>