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.EntrySetNested classes/interfaces inherited from interface com.google.common.collect.Multiset
Multiset.Entry<E> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintAdds a number of occurrences of an element to this multiset.intReturns 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()intRemoves a number of occurrences of the specified element from this multiset.Methods inherited from class com.google.common.collect.Multisets.ViewMultiset
clear, distinctElements, sizeMethods inherited from class com.google.common.collect.AbstractMultiset
add, addAll, contains, elementSet, entrySet, equals, hashCode, isEmpty, remove, removeAll, retainAll, setCount, 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, forEachEntry, spliterator
-
Field Details
-
unfiltered
-
predicate
-
-
Constructor Details
-
FilteredMultiset
-
-
Method Details
-
iterator
Description copied from interface:MultisetElements that occur multiple times in the multiset will appear multiple times in this iterator, though not necessarily sequentially.
-
createElementSet
Description copied from class:AbstractMultisetCreates a new instance of this multiset's element set, which will be returned byAbstractMultiset.elementSet().- Overrides:
createElementSetin classAbstractMultiset<E>
-
elementIterator
- Specified by:
elementIteratorin classAbstractMultiset<E>
-
createEntrySet
Set<Multiset.Entry<E>> createEntrySet()- Overrides:
createEntrySetin classAbstractMultiset<E>
-
entryIterator
Iterator<Multiset.Entry<E>> entryIterator()- Specified by:
entryIteratorin classAbstractMultiset<E>
-
count
Description copied from interface:MultisetReturns 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:MultisetAdds 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:
addin interfaceMultiset<E>- Overrides:
addin 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:MultisetRemoves 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:
removein interfaceMultiset<E>- Overrides:
removein 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
-