@GwtCompatible(serializable=true) class RegularImmutableMultiset<E> extends ImmutableMultiset<E>
ImmutableMultiset
with zero or more elements.ImmutableMultiset.Builder<E>, ImmutableMultiset.EntrySetSerializedForm<E>
ImmutableCollection.ArrayBasedBuilder<E>
Multiset.Entry<E>
Modifier and Type | Field and Description |
---|---|
private ImmutableMap<E,java.lang.Integer> |
map |
private int |
size |
Constructor and Description |
---|
RegularImmutableMultiset(ImmutableMap<E,java.lang.Integer> map,
int size) |
Modifier and Type | Method and Description |
---|---|
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).
|
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, builder, containsAll, copyFromEntries, copyIntoArray, copyOf, copyOf, copyOf, entrySet, equals, iterator, of, of, of, of, of, of, of, remove, setCount, setCount, toString, writeReplace
add, addAll, asList, clear, createAsList, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, remove, removeAll, retainAll
private final transient ImmutableMap<E,java.lang.Integer> map
private final transient int size
RegularImmutableMultiset(ImmutableMap<E,java.lang.Integer> map, int size)
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 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 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.