public final class LinkedHashMultiset<E> extends AbstractMapBasedMultiset<E>
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.
AbstractMultiset.ElementSet, AbstractMultiset.EntrySetMultiset.Entry<E>| Modifier and Type | Field and Description |
|---|---|
private static long |
serialVersionUID |
| Modifier | Constructor and Description |
|---|---|
private |
LinkedHashMultiset() |
private |
LinkedHashMultiset(int distinctElements) |
| Modifier and Type | Method and Description |
|---|---|
static <E> LinkedHashMultiset<E> |
create()
Creates a new, empty
LinkedHashMultiset using the default initial capacity. |
static <E> LinkedHashMultiset<E> |
create(int distinctElements)
Creates a new, empty
LinkedHashMultiset with the specified expected number of distinct
elements. |
static <E> LinkedHashMultiset<E> |
create(java.lang.Iterable<? extends E> elements)
Creates a new
LinkedHashMultiset containing the specified elements. |
private void |
readObject(java.io.ObjectInputStream stream) |
private void |
writeObject(java.io.ObjectOutputStream stream) |
add, clear, count, distinctElements, elementIterator, entryIterator, entrySet, forEachEntry, iterator, remove, setBackingMap, setCount, sizeadd, addAll, contains, createElementSet, createEntrySet, elementSet, equals, hashCode, isEmpty, remove, removeAll, retainAll, setCount, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcontainsAll, forEach, spliteratorprivate static final long serialVersionUID
private LinkedHashMultiset()
private LinkedHashMultiset(int distinctElements)
public static <E> LinkedHashMultiset<E> create()
LinkedHashMultiset using the default initial capacity.public static <E> LinkedHashMultiset<E> create(int distinctElements)
LinkedHashMultiset with the specified expected number of distinct
elements.distinctElements - the expected number of distinct elementsjava.lang.IllegalArgumentException - if distinctElements is negativepublic static <E> LinkedHashMultiset<E> create(java.lang.Iterable<? extends E> elements)
LinkedHashMultiset containing the specified elements.
This implementation is highly efficient when elements is itself a Multiset.
elements - the elements that the multiset should containprivate void writeObject(java.io.ObjectOutputStream stream)
throws java.io.IOException
java.io.IOExceptionprivate void readObject(java.io.ObjectInputStream stream)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOExceptionjava.lang.ClassNotFoundException