@GwtCompatible(serializable=true) class RegularImmutableMultiset<E> extends ImmutableMultiset<E>
ImmutableMultiset
with zero or more elements.Modifier and Type | Class and Description |
---|---|
private class |
RegularImmutableMultiset.ElementSet |
private static class |
RegularImmutableMultiset.NonTerminalEntry<E> |
ImmutableMultiset.Builder<E>, ImmutableMultiset.EntrySetSerializedForm<E>
ImmutableCollection.ArrayBasedBuilder<E>
Multiset.Entry<E>
Modifier and Type | Field and Description |
---|---|
private ImmutableSet<E> |
elementSet |
(package private) static RegularImmutableMultiset<java.lang.Object> |
EMPTY |
private Multisets.ImmutableEntry<E>[] |
entries |
private int |
hashCode |
private Multisets.ImmutableEntry<E>[] |
hashTable |
private int |
size |
Constructor and Description |
---|
RegularImmutableMultiset(java.util.Collection<? extends Multiset.Entry<? extends E>> entries) |
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).
|
ImmutableSet<E> |
elementSet()
Returns the set of distinct elements contained in this multiset.
|
(package private) Multiset.Entry<E> |
getEntry(int index) |
int |
hashCode()
Returns the hash code for this multiset.
|
(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() |
add, asList, builder, contains, copyFromEntries, copyIntoArray, copyOf, copyOf, copyOf, createAsList, entrySet, equals, iterator, of, of, of, of, of, of, of, remove, setCount, setCount, toString, writeReplace
add, addAll, clear, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, containsAll, remove, removeAll, retainAll
static final RegularImmutableMultiset<java.lang.Object> EMPTY
private final transient Multisets.ImmutableEntry<E>[] entries
private final transient Multisets.ImmutableEntry<E>[] hashTable
private final transient int size
private final transient int hashCode
private transient ImmutableSet<E> elementSet
RegularImmutableMultiset(java.util.Collection<? extends Multiset.Entry<? extends E>> entries)
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 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.
element
- the element to count occurrences ofpublic int size()
public 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()
.
Multiset.Entry<E> getEntry(int index)
getEntry
in class ImmutableMultiset<E>
public int hashCode()
Multiset
((element == null) ? 0 : element.hashCode()) ^ count(element)
over all distinct elements in the multiset. It follows that a multiset and its entry set always have the same hash code.