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>,Serializable,Iterable<E>,Collection<E>
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.
- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.collect.AbstractMultiset
AbstractMultiset.ElementSet, AbstractMultiset.EntrySetNested classes/interfaces inherited from interface com.google.common.collect.Multiset
Multiset.Entry<E> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> LinkedHashMultiset<E>create()Creates a new, emptyLinkedHashMultisetusing the default initial capacity.static <E> LinkedHashMultiset<E>create(int distinctElements) Creates a new, emptyLinkedHashMultisetwith the specified expected number of distinct elements.static <E> LinkedHashMultiset<E>Creates a newLinkedHashMultisetcontaining the specified elements.private voidreadObject(ObjectInputStream stream) private voidwriteObject(ObjectOutputStream stream) Methods inherited from class com.google.common.collect.AbstractMapBasedMultiset
add, clear, count, distinctElements, elementIterator, entryIterator, entrySet, forEachEntry, iterator, remove, setBackingMap, setCount, sizeMethods inherited from class com.google.common.collect.AbstractMultiset
add, addAll, contains, createElementSet, createEntrySet, elementSet, equals, hashCode, isEmpty, remove, removeAll, retainAll, setCount, toStringMethods inherited from class java.util.AbstractCollection
containsAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray, toArray, toArrayMethods inherited from interface com.google.common.collect.Multiset
containsAll, forEach, spliterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
LinkedHashMultiset
private LinkedHashMultiset() -
LinkedHashMultiset
private LinkedHashMultiset(int distinctElements)
-
-
Method Details
-
create
Creates a new, emptyLinkedHashMultisetusing the default initial capacity. -
create
Creates a new, emptyLinkedHashMultisetwith the specified expected number of distinct elements.- Parameters:
distinctElements- the expected number of distinct elements- Throws:
IllegalArgumentException- ifdistinctElementsis negative
-
create
Creates a newLinkedHashMultisetcontaining the specified elements.This implementation is highly efficient when
elementsis itself aMultiset.- Parameters:
elements- the elements that the multiset should contain
-
writeObject
- Throws:
IOException
-
readObject
- Throws:
IOExceptionClassNotFoundException
-