class RegularImmutableMultiset<E> extends ImmutableMultiset<E>
ImmutableMultiset
with zero or more elements.Modifier and Type | Class and Description |
---|---|
private static class |
RegularImmutableMultiset.NonTerminalEntry<E> |
ImmutableMultiset.Builder<E>, ImmutableMultiset.ElementSet<E>, ImmutableMultiset.EntrySetSerializedForm<E>, ImmutableMultiset.SerializedForm
Multiset.Entry<E>
Modifier and Type | Field and Description |
---|---|
private ImmutableSet<E> |
elementSet |
(package private) static ImmutableMultiset<java.lang.Object> |
EMPTY |
private static Multisets.ImmutableEntry<?>[] |
EMPTY_ARRAY |
private Multisets.ImmutableEntry<E>[] |
entries |
(package private) static double |
HASH_FLOODING_FPP
Maximum allowed false positive probability of detecting a hash flooding attack given random
input.
|
private int |
hashCode |
private Multisets.ImmutableEntry<?>[] |
hashTable |
(package private) static int |
MAX_HASH_BUCKET_LENGTH
Maximum allowed length of a hash table bucket before falling back to a j.u.HashMap based
implementation.
|
(package private) static double |
MAX_LOAD_FACTOR
Closed addressing tends to perform well even with high load factors.
|
private int |
size |
SPLITERATOR_CHARACTERISTICS
Modifier | Constructor and Description |
---|---|
private |
RegularImmutableMultiset(Multisets.ImmutableEntry<E>[] entries,
Multisets.ImmutableEntry<?>[] hashTable,
int size,
int hashCode,
ImmutableSet<E> elementSet) |
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) |
int |
hashCode()
Returns the hash code for this multiset.
|
private static boolean |
hashFloodingDetected(Multisets.ImmutableEntry<?>[] hashTable) |
(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, 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 static final Multisets.ImmutableEntry<?>[] EMPTY_ARRAY
static final ImmutableMultiset<java.lang.Object> EMPTY
static final double MAX_LOAD_FACTOR
static final double HASH_FLOODING_FPP
static final int MAX_HASH_BUCKET_LENGTH
private final transient Multisets.ImmutableEntry<E>[] entries
private final transient Multisets.ImmutableEntry<?>[] hashTable
private final transient int size
private final transient int hashCode
@CheckForNull private transient ImmutableSet<E> elementSet
private RegularImmutableMultiset(Multisets.ImmutableEntry<E>[] entries, Multisets.ImmutableEntry<?>[] hashTable, int size, int hashCode, @CheckForNull ImmutableSet<E> elementSet)
static <E> ImmutableMultiset<E> create(java.util.Collection<? extends Multiset.Entry<? extends E>> entries)
private static boolean hashFloodingDetected(Multisets.ImmutableEntry<?>[] hashTable)
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(@CheckForNull 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()
Multiset
Note: this method does not return the number of distinct elements in the
multiset, which is given by entrySet().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()
.
elementSet
in interface Multiset<E>
elementSet
in class ImmutableMultiset<E>
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.