Package com.google.common.collect
Class Multisets.FilteredMultiset<E>
java.lang.Object
java.util.AbstractCollection<E>
com.google.common.collect.AbstractMultiset<E>
com.google.common.collect.Multisets.ViewMultiset<E>
com.google.common.collect.Multisets.FilteredMultiset<E>
- All Implemented Interfaces:
Multiset<E>
,Iterable<E>
,Collection<E>
- Enclosing class:
Multisets
-
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 TypeMethodDescriptionint
Adds a number of occurrences of an element to this multiset.int
Returns the number of occurrences of an element in this multiset (the count of the element).Creates a new instance of this multiset's element set, which will be returned byAbstractMultiset.elementSet()
.(package private) Set
<Multiset.Entry<E>> (package private) Iterator
<Multiset.Entry<E>> iterator()
int
Removes a number of occurrences of the specified element from this multiset.Methods inherited from class com.google.common.collect.Multisets.ViewMultiset
clear, distinctElements, size
Methods inherited from class com.google.common.collect.AbstractMultiset
add, addAll, contains, elementSet, entrySet, equals, hashCode, isEmpty, remove, removeAll, retainAll, setCount, 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, forEachEntry, spliterator
-
Field Details
-
unfiltered
-
predicate
-
-
Constructor Details
-
FilteredMultiset
-
-
Method Details
-
iterator
Description copied from interface:Multiset
Elements that occur multiple times in the multiset will appear multiple times in this iterator, though not necessarily sequentially.
-
createElementSet
Description copied from class:AbstractMultiset
Creates a new instance of this multiset's element set, which will be returned byAbstractMultiset.elementSet()
.- Overrides:
createElementSet
in classAbstractMultiset<E>
-
elementIterator
- Specified by:
elementIterator
in classAbstractMultiset<E>
-
createEntrySet
Set<Multiset.Entry<E>> createEntrySet()- Overrides:
createEntrySet
in classAbstractMultiset<E>
-
entryIterator
Iterator<Multiset.Entry<E>> entryIterator()- Specified by:
entryIterator
in classAbstractMultiset<E>
-
count
Description copied from interface:Multiset
Returns the number of occurrences of an element in this multiset (the count of the element). Note that for anObject.equals(java.lang.Object)
-based multiset, this gives the same result asCollections.frequency(java.util.Collection<?>, java.lang.Object)
(which would presumably perform more poorly).Note: the utility method
Iterables.frequency(java.lang.Iterable<?>, java.lang.Object)
generalizes this operation; it correctly delegates to this method when dealing with a multiset, but it can also accept any other iterable type.- Parameters:
element
- the element to count occurrences of- Returns:
- the number of occurrences of the element in this multiset; possibly zero but never negative
-
add
Description copied from interface:Multiset
Adds a number of occurrences of an element to this multiset. Note that ifoccurrences == 1
, this method has the identical effect toMultiset.add(Object)
. This method is functionally equivalent (except in the case of overflow) to the calladdAll(Collections.nCopies(element, occurrences))
, which would presumably perform much more poorly.- Specified by:
add
in interfaceMultiset<E>
- Overrides:
add
in classAbstractMultiset<E>
- Parameters:
element
- the element to add occurrences of; may be null only if explicitly allowed by the implementationoccurrences
- the number of occurrences of the element to add. May be zero, in which case no change will be made.- Returns:
- the count of the element before the operation; possibly zero
-
remove
Description copied from interface:Multiset
Removes a number of occurrences of the specified element from this multiset. If the multiset contains fewer than this number of occurrences to begin with, all occurrences will be removed. Note that ifoccurrences == 1
, this is functionally equivalent to the callremove(element)
.- Specified by:
remove
in interfaceMultiset<E>
- Overrides:
remove
in classAbstractMultiset<E>
- Parameters:
element
- the element to conditionally remove occurrences ofoccurrences
- the number of occurrences of the element to remove. May be zero, in which case no change will be made.- Returns:
- the count of the element before the operation; possibly zero
-