Package com.google.common.collect
Class LinkedHashMultiset<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- com.google.common.collect.AbstractMultiset<E>
-
- com.google.common.collect.AbstractMapBasedMultiset<E>
-
- com.google.common.collect.LinkedHashMultiset<E>
-
- All Implemented Interfaces:
Multiset<E>
,java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
@GwtCompatible(serializable=true, emulated=true) public final class LinkedHashMultiset<E> extends AbstractMapBasedMultiset<E>
AMultiset
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
.- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.AbstractMultiset
AbstractMultiset.ElementSet, AbstractMultiset.EntrySet
-
Nested classes/interfaces inherited from interface com.google.common.collect.Multiset
Multiset.Entry<E>
-
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description private
LinkedHashMultiset()
private
LinkedHashMultiset(int distinctElements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <E> LinkedHashMultiset<E>
create()
Creates a new, emptyLinkedHashMultiset
using the default initial capacity.static <E> LinkedHashMultiset<E>
create(int distinctElements)
Creates a new, emptyLinkedHashMultiset
with the specified expected number of distinct elements.static <E> LinkedHashMultiset<E>
create(java.lang.Iterable<? extends E> elements)
Creates a newLinkedHashMultiset
containing the specified elements.private void
readObject(java.io.ObjectInputStream stream)
private void
writeObject(java.io.ObjectOutputStream stream)
-
Methods inherited from class com.google.common.collect.AbstractMapBasedMultiset
add, clear, count, distinctElements, entryIterator, entrySet, iterator, remove, setBackingMap, setCount, size
-
Methods inherited from class com.google.common.collect.AbstractMultiset
add, addAll, contains, createElementSet, createEntrySet, elementSet, equals, hashCode, isEmpty, remove, removeAll, retainAll, setCount, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray, toArray, toArray
-
Methods inherited from interface com.google.common.collect.Multiset
containsAll
-
-
-
-
Field Detail
-
serialVersionUID
@GwtIncompatible private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public static <E> LinkedHashMultiset<E> create()
Creates a new, emptyLinkedHashMultiset
using the default initial capacity.
-
create
public static <E> LinkedHashMultiset<E> create(int distinctElements)
Creates a new, emptyLinkedHashMultiset
with the specified expected number of distinct elements.- Parameters:
distinctElements
- the expected number of distinct elements- Throws:
java.lang.IllegalArgumentException
- ifdistinctElements
is negative
-
create
public static <E> LinkedHashMultiset<E> create(java.lang.Iterable<? extends E> elements)
Creates a newLinkedHashMultiset
containing the specified elements.This implementation is highly efficient when
elements
is itself aMultiset
.- Parameters:
elements
- the elements that the multiset should contain
-
writeObject
@GwtIncompatible private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
readObject
@GwtIncompatible private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-