Package com.google.common.collect
Class HashMultiset<E>
java.lang.Object
java.util.AbstractCollection<E>
com.google.common.collect.AbstractMultiset<E>
com.google.common.collect.AbstractMapBasedMultiset<E>
com.google.common.collect.HashMultiset<E>
- All Implemented Interfaces:
Multiset<E>
,Serializable
,Iterable<E>
,Collection<E>
Multiset implementation backed by a
HashMap
.- Since:
- 2.0
- See Also:
-
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> HashMultiset
<E> create()
Creates a new, emptyHashMultiset
using the default initial capacity.static <E> HashMultiset
<E> create
(int distinctElements) Creates a new, emptyHashMultiset
with the specified expected number of distinct elements.static <E> HashMultiset
<E> Creates a newHashMultiset
containing the specified elements.private void
readObject
(ObjectInputStream stream) private void
writeObject
(ObjectOutputStream stream) Methods inherited from class com.google.common.collect.AbstractMapBasedMultiset
add, clear, count, distinctElements, elementIterator, entryIterator, entrySet, forEachEntry, 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.util.AbstractCollection
containsAll, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray, toArray, toArray
Methods inherited from interface com.google.common.collect.Multiset
containsAll, forEach, spliterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
HashMultiset
private HashMultiset() -
HashMultiset
private HashMultiset(int distinctElements)
-
-
Method Details
-
create
Creates a new, emptyHashMultiset
using the default initial capacity. -
create
Creates a new, emptyHashMultiset
with the specified expected number of distinct elements.- Parameters:
distinctElements
- the expected number of distinct elements- Throws:
IllegalArgumentException
- ifdistinctElements
is negative
-
create
Creates a newHashMultiset
containing the specified elements.This implementation is highly efficient when
elements
is itself aMultiset
.- Parameters:
elements
- the elements that the multiset should contain
-
writeObject
- Throws:
IOException
-
readObject
- Throws:
IOException
ClassNotFoundException
-