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

public final Class LinkedHashMultiset<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.LinkedHashMap, org.checkerframework.checker.nullness.qual.Nullable

A Multiset implementation with predictable iteration order. Its iterator orders elements according to when the first occurrence of the element was added. When the multiset contains multiple instances of an element, those instances are consecutive in the iteration order. If all occurrences of an element are removed, after which that element is added to the multiset, the element will appear at the end of the iteration.

See the Guava User Guide article on Multiset.

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
LinkedHashMultiset(int distinctElements)

Method Summary

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

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

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

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

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

Creates a new LinkedHashMultiset 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

LinkedHashMultisetback to summary
private LinkedHashMultiset()
LinkedHashMultisetback to summary
private LinkedHashMultiset(int distinctElements)

Method Detail

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

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

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

Creates a new, empty LinkedHashMultiset 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> LinkedHashMultiset<E> create(Iterable<? extends E> elements)

Creates a new LinkedHashMultiset 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