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

pack-priv final Class JdkBackedImmutableMultiset<E>

extends ImmutableMultiset<E>
Class Inheritance
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

An implementation of ImmutableMultiset backed by a JDK Map and a list of entries. Used to protect against hash flooding attacks.
Author
Louis Wasserman

Field Summary

Modifier and TypeField and Description
private final Map<E, Integer>
private transient ImmutableSet<E>
private final ImmutableList<Multiset.Entry<E>>
private final long

Constructor Summary

AccessConstructor and Description
private
JdkBackedImmutableMultiset(Map<E, Integer> delegateMap, ImmutableList<Multiset.Entry<E>> entries, long size)

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>
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.
pack-priv Object
Inherited from com.google.common.collect.ImmutableMultiset:
addasListbuildercontainscopyFromEntriescopyIntoArraycopyOfcopyOfcopyOfentrySetequalshashCodeiteratorofofofofofofofremovesetCountsetCounttoImmutableMultisettoImmutableMultisettoString

Field Detail

delegateMapback to summary
private final Map<E, Integer> delegateMap
elementSetback to summary
private transient ImmutableSet<E> elementSet
Annotations
@LazyInit
@CheckForNull
entriesback to summary
private final ImmutableList<Multiset.Entry<E>> entries
sizeback to summary
private final long size

Constructor Detail

JdkBackedImmutableMultisetback to summary
private JdkBackedImmutableMultiset(Map<E, Integer> delegateMap, ImmutableList<Multiset.Entry<E>> entries, long size)

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
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
writeReplaceback to summary
pack-priv Object writeReplace()

Overrides com.google.common.collect.ImmutableMultiset.writeReplace.

Annotations
@SuppressWarnings:RedundantOverride
@Override
@J2ktIncompatible
@GwtIncompatible