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

public final Class HashMultiset<E extends @Nullable Object>

extends AbstractMapBasedMultiset<E extends @Nullable Object>
Class Inheritance
Annotations
@GwtCompatible
serializable:true
emulated:true
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.GwtCompatible, .GwtIncompatible, .J2ktIncompatible, java.io.IOException, .ObjectInputStream, .ObjectOutputStream, java.util.HashMap, org.checkerframework.checker.nullness.qual.Nullable

Multiset implementation backed by a HashMap.
Authors
Kevin Bourrillion, Jared Levy
Since
2.0

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
private
private
HashMultiset(int distinctElements)

Method Summary

Modifier and TypeMethod and Description
public static <E extends @Nullable Object> HashMultiset<E>
create()

Creates a new, empty HashMultiset using the default initial capacity.

public static <E extends @Nullable Object> HashMultiset<E>
create(int
the expected number of distinct elements
distinctElements
)

Creates a new, empty HashMultiset with the specified expected number of distinct elements.

public static <E extends @Nullable Object> HashMultiset<E>
create(Iterable<? extends E>
the elements that the multiset should contain
elements
)

Creates a new HashMultiset containing the specified elements.

private void
private void
Inherited from com.google.common.collect.AbstractMapBasedMultiset:
addclearcountdistinctElementselementIteratorentryIteratorentrySetforEachEntryiteratorremovesetBackingMapsetCountsize

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.google.common.collect.AbstractMapBasedMultiset.serialVersionUID.

Annotations
@GwtIncompatible
@J2ktIncompatible

Constructor Detail

HashMultisetback to summary
private HashMultiset()
HashMultisetback to summary
private HashMultiset(int distinctElements)

Method Detail

createback to summary
public static <E extends @Nullable Object> HashMultiset<E> create()

Creates a new, empty HashMultiset using the default initial capacity.

createback to summary
public static <E extends @Nullable Object> HashMultiset<E> create(int distinctElements)

Creates a new, empty HashMultiset with the specified expected number of distinct elements.

Parameters
distinctElements:int

the expected number of distinct elements

Exceptions
IllegalArgumentException:
if distinctElements is negative
createback to summary
public static <E extends @Nullable Object> HashMultiset<E> create(Iterable<? extends E> elements)

Creates a new HashMultiset containing the specified elements.

This implementation is highly efficient when elements is itself a Multiset.

Parameters
elements:Iterable<? extends E>

the elements that the multiset should contain

readObjectback to summary
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
Annotations
@GwtIncompatible
@J2ktIncompatible
writeObjectback to summary
private void writeObject(ObjectOutputStream stream) throws IOException
Annotations
@GwtIncompatible
@J2ktIncompatible
Serial data
the number of distinct elements, the first element, its count, the second element, its count, and so on