Top Description Inners Fields Constructors Methods
com.google.common.collect

pack-priv Class RegularImmutableMultiset<E>

extends ImmutableMultiset<E>
Class Inheritance
Annotations
@GwtCompatible
emulated:true
serializable:true
@SuppressWarnings:serial
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

Implementation of ImmutableMultiset with zero or more elements.
Authors
Jared Levy, Louis Wasserman

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private transient ImmutableSet<E>
pack-priv static final ImmutableMultiset<Object>
private static final Multisets.ImmutableEntry<?>[]
private final transient Multisets.ImmutableEntry<E>[]
pack-priv static final double
HASH_FLOODING_FPP

Maximum allowed false positive probability of detecting a hash flooding attack given random input.

private final transient int
private final transient @Nullable Multisets.ImmutableEntry<?>[]
pack-priv static final int
MAX_HASH_BUCKET_LENGTH

Maximum allowed length of a hash table bucket before falling back to a j.u.HashMap based implementation.

pack-priv static final double
MAX_LOAD_FACTOR

Closed addressing tends to perform well even with high load factors.

private final transient int

Constructor Summary

AccessConstructor and Description
private
RegularImmutableMultiset(Multisets.ImmutableEntry<E>[] entries, @Nullable Multisets.ImmutableEntry<?>[] hashTable, int size, int hashCode, ImmutableSet<E> elementSet)

Method Summary

Modifier and TypeMethod and Description
public int
count(Object
the element to count occurrences of
element
)

Implements com.google.common.collect.Multiset.count.

Returns the number of occurrences of an element in this multiset (the count of the element).
pack-priv static <E> ImmutableMultiset<E>
create(Collection<? extends Multiset.Entry<? extends E>> entries)

public ImmutableSet<E>
elementSet()

Implements abstract com.google.common.collect.ImmutableMultiset.elementSet.

Implements com.google.common.collect.Multiset.elementSet.

Returns the set of distinct elements contained in this multiset.
pack-priv Multiset.Entry<E>
public int
private static boolean
pack-priv boolean
isPartialView()

Implements abstract com.google.common.collect.ImmutableCollection.isPartialView.

Returns true if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods.
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements com.google.common.collect.Multiset.size, java.util.Collection.size.

Returns the total number of all occurrences of all elements in this multiset.
Inherited from com.google.common.collect.ImmutableMultiset:
addasListbuildercontainscopyFromEntriescopyIntoArraycopyOfcopyOfcopyOfentrySetequalsiteratorofofofofofofofremovesetCountsetCounttoImmutableMultisettoImmutableMultisettoStringwriteReplace

Field Detail

elementSetback to summary
private transient ImmutableSet<E> elementSet
Annotations
@LazyInit
@CheckForNull
EMPTYback to summary
pack-priv static final ImmutableMultiset<Object> EMPTY
EMPTY_ARRAYback to summary
private static final Multisets.ImmutableEntry<?>[] EMPTY_ARRAY

Hides com.google.common.collect.ImmutableCollection.EMPTY_ARRAY.

entriesback to summary
private final transient Multisets.ImmutableEntry<E>[] entries
HASH_FLOODING_FPPback to summary
pack-priv static final double HASH_FLOODING_FPP

Maximum allowed false positive probability of detecting a hash flooding attack given random input.

Annotations
@VisibleForTesting
hashCodeback to summary
private final transient int hashCode
hashTableback to summary
private final transient @Nullable Multisets.ImmutableEntry<?>[] hashTable
MAX_HASH_BUCKET_LENGTHback to summary
pack-priv static final int MAX_HASH_BUCKET_LENGTH

Maximum allowed length of a hash table bucket before falling back to a j.u.HashMap based implementation. Experimentally determined.

Annotations
@VisibleForTesting
MAX_LOAD_FACTORback to summary
pack-priv static final double MAX_LOAD_FACTOR

Closed addressing tends to perform well even with high load factors. Being conservative here ensures that the table is still likely to be relatively sparse (hence it misses fast) while saving space.

Annotations
@VisibleForTesting
sizeback to summary
private final transient int size

Constructor Detail

RegularImmutableMultisetback to summary
private RegularImmutableMultiset(Multisets.ImmutableEntry<E>[] entries, @Nullable Multisets.ImmutableEntry<?>[] hashTable, int size, int hashCode, ImmutableSet<E> elementSet)

Method Detail

countback to summary
public int count(Object element)

Implements com.google.common.collect.Multiset.count.

Doc from com.google.common.collect.Multiset.count.

Returns the number of occurrences of an element in this multiset (the count of the element). Note that for an Object#equals-based multiset, this gives the same result as Collections#frequency (which would presumably perform more poorly).

Note

the utility method Iterables#frequency generalizes this operation; it correctly delegates to this method when dealing with a multiset, but it can also accept any other iterable type.

Parameters
element:Object

the element to count occurrences of

Returns:int

the number of occurrences of the element in this multiset; possibly zero but never negative

Annotations
@Override
createback to summary
pack-priv static <E> ImmutableMultiset<E> create(Collection<? extends Multiset.Entry<? extends E>> entries)
elementSetback to summary
public ImmutableSet<E> elementSet()

Implements abstract com.google.common.collect.ImmutableMultiset.elementSet.

Implements com.google.common.collect.Multiset.elementSet.

Doc from com.google.common.collect.Multiset.elementSet.

Returns the set of distinct elements contained in this multiset. The element set is backed by the same data as the multiset, so any change to either is immediately reflected in the other. The order of the elements in the element set is unspecified.

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().

Returns:ImmutableSet<E>

a view of the set of distinct elements in this multiset

Annotations
@Override
getEntryback to summary
pack-priv Multiset.Entry<E> getEntry(int index)

Implements abstract com.google.common.collect.ImmutableMultiset.getEntry.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides com.google.common.collect.ImmutableMultiset.hashCode.

Implements com.google.common.collect.Multiset.hashCode, java.util.Collection.hashCode.

Doc from com.google.common.collect.Multiset.hashCode.

Returns the hash code for this multiset. This is defined as the sum of

((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.

Returns:int

Doc from java.util.Collection.hashCode.

the hash code value for this collection

Annotations
@Override
hashFloodingDetectedback to summary
private static boolean hashFloodingDetected(@Nullable Multisets.ImmutableEntry<?>[] hashTable)
isPartialViewback to summary
pack-priv boolean isPartialView()

Implements abstract com.google.common.collect.ImmutableCollection.isPartialView.

Doc from com.google.common.collect.ImmutableCollection.isPartialView.

Returns 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.

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements com.google.common.collect.Multiset.size, java.util.Collection.size.

Doc from com.google.common.collect.Multiset.size.

Returns the total number of all occurrences of all elements in this multiset.

Note

this method does not return the number of distinct elements in the multiset, which is given by entrySet().size().

Returns:int

Doc from java.util.Collection.size.

the number of elements in this collection

Annotations
@Override
com.google.common.collect back to summary

private final Class RegularImmutableMultiset.NonTerminalEntry<E>

extends Multisets.ImmutableEntry<E>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Multisets.ImmutableEntry<E>

Constructor Summary

AccessConstructor and Description
pack-priv
NonTerminalEntry(E element, int count, Multisets.ImmutableEntry<E> nextInBucket)

Method Summary

Modifier and TypeMethod and Description
public Multisets.ImmutableEntry<E>
Inherited from com.google.common.collect.Multisets.ImmutableEntry:
getCountgetElement

Field Detail

nextInBucketback to summary
private final Multisets.ImmutableEntry<E> nextInBucket

Constructor Detail

NonTerminalEntryback to summary
pack-priv NonTerminalEntry(E element, int count, Multisets.ImmutableEntry<E> nextInBucket)

Method Detail

nextInBucketback to summary
public Multisets.ImmutableEntry<E> nextInBucket()

Overrides com.google.common.collect.Multisets.ImmutableEntry.nextInBucket.

Annotations
@Override