@GwtCompatible final class JdkBackedImmutableMultiset<E> extends ImmutableMultiset<E>
ImmutableMultiset.Builder<E>, ImmutableMultiset.ElementSet<E>, ImmutableMultiset.EntrySetSerializedForm<E>, ImmutableMultiset.SerializedForm
Multiset.Entry<E>
Modifier and Type | Field and Description |
---|---|
private java.util.Map<E,java.lang.Integer> |
delegateMap |
private ImmutableSet<E> |
elementSet |
private ImmutableList<Multiset.Entry<E>> |
entries |
private long |
size |
SPLITERATOR_CHARACTERISTICS
Modifier | Constructor and Description |
---|---|
private |
JdkBackedImmutableMultiset(java.util.Map<E,java.lang.Integer> delegateMap,
ImmutableList<Multiset.Entry<E>> entries,
long size) |
Modifier and Type | Method and Description |
---|---|
int |
count(java.lang.Object element)
Returns the number of occurrences of an element in this multiset (the count of the
element).
|
(package private) static <E> ImmutableMultiset<E> |
create(java.util.Collection<? extends Multiset.Entry<? extends E>> entries) |
ImmutableSet<E> |
elementSet()
Returns the set of distinct elements contained in this multiset.
|
(package private) Multiset.Entry<E> |
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.
|
add, asList, builder, contains, copyFromEntries, copyIntoArray, copyOf, copyOf, copyOf, entrySet, equals, hashCode, iterator, of, of, of, of, of, of, of, remove, setCount, setCount, toImmutableMultiset, toImmutableMultiset, toString, writeReplace
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
private final java.util.Map<E,java.lang.Integer> delegateMap
private final ImmutableList<Multiset.Entry<E>> entries
private final long size
private transient ImmutableSet<E> elementSet
private JdkBackedImmutableMultiset(java.util.Map<E,java.lang.Integer> delegateMap, ImmutableList<Multiset.Entry<E>> entries, long size)
static <E> ImmutableMultiset<E> create(java.util.Collection<? extends Multiset.Entry<? extends E>> entries)
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<E> 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<E>
elementSet
in class ImmutableMultiset<E>
Multiset.Entry<E> getEntry(int index)
getEntry
in class ImmutableMultiset<E>
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<E>
public int size()
Multiset
Note: this method does not return the number of distinct elements in the
multiset, which is given by entrySet().size()
.