Class DescendingImmutableSortedMultiset<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- com.google.common.collect.ImmutableCollection<E>
-
- com.google.common.collect.ImmutableMultisetGwtSerializationDependencies<E>
-
- com.google.common.collect.ImmutableMultiset<E>
-
- com.google.common.collect.ImmutableSortedMultisetFauxverideShim<E>
-
- com.google.common.collect.ImmutableSortedMultiset<E>
-
- com.google.common.collect.DescendingImmutableSortedMultiset<E>
-
- All Implemented Interfaces:
Multiset<E>
,SortedIterable<E>
,SortedMultiset<E>
,SortedMultisetBridge<E>
,java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
@GwtIncompatible final class DescendingImmutableSortedMultiset<E> extends ImmutableSortedMultiset<E>
A descending wrapper around anImmutableSortedMultiset
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableSortedMultiset
ImmutableSortedMultiset.Builder<E>
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableMultiset
ImmutableMultiset.ElementSet<E>, ImmutableMultiset.EntrySetSerializedForm<E>
-
Nested classes/interfaces inherited from interface com.google.common.collect.Multiset
Multiset.Entry<E>
-
-
Field Summary
Fields Modifier and Type Field Description private ImmutableSortedMultiset<E>
forward
-
Fields inherited from class com.google.common.collect.ImmutableSortedMultiset
descendingMultiset
-
Fields inherited from class com.google.common.collect.ImmutableCollection
SPLITERATOR_CHARACTERISTICS
-
-
Constructor Summary
Constructors Constructor Description DescendingImmutableSortedMultiset(ImmutableSortedMultiset<E> forward)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
count(java.lang.Object element)
Returns the number of occurrences of an element in this multiset (the count of the element).ImmutableSortedMultiset<E>
descendingMultiset()
Returns a descending view of this multiset.ImmutableSortedSet<E>
elementSet()
Returns the set of distinct elements contained in this multiset.Multiset.Entry<E>
firstEntry()
Returns the entry of the first element in this multiset, ornull
if this multiset is empty.(package private) Multiset.Entry<E>
getEntry(int index)
ImmutableSortedMultiset<E>
headMultiset(E upperBound, BoundType boundType)
Returns a view of this multiset restricted to the elements less thanupperBound
, optionally includingupperBound
itself.(package private) boolean
isPartialView()
Returnstrue
if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods.Multiset.Entry<E>
lastEntry()
Returns the entry of the last element in this multiset, ornull
if this multiset is empty.int
size()
Returns the total number of all occurrences of all elements in this multiset.ImmutableSortedMultiset<E>
tailMultiset(E lowerBound, BoundType boundType)
Returns a view of this multiset restricted to the elements greater thanlowerBound
, optionally includinglowerBound
itself.-
Methods inherited from class com.google.common.collect.ImmutableSortedMultiset
comparator, copyOf, copyOf, copyOf, copyOf, copyOf, copyOfSorted, emptyMultiset, naturalOrder, of, of, of, of, of, of, of, orderedBy, pollFirstEntry, pollLastEntry, reverseOrder, subMultiset, toImmutableSortedMultiset, toImmutableSortedMultiset, writeReplace
-
Methods inherited from class com.google.common.collect.ImmutableSortedMultisetFauxverideShim
builder, copyOf, of, of, of, of, of, of, toImmutableMultiset, toImmutableMultiset
-
Methods inherited from class com.google.common.collect.ImmutableMultiset
add, asList, contains, copyFromEntries, copyIntoArray, entrySet, equals, hashCode, iterator, remove, setCount, setCount, toString
-
Methods inherited from class com.google.common.collect.ImmutableCollection
add, addAll, clear, internalArray, internalArrayEnd, internalArrayStart, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
addAll, clear, isEmpty, parallelStream, removeIf, stream, toArray, toArray, toArray
-
Methods inherited from interface com.google.common.collect.Multiset
add, add, contains, containsAll, equals, forEach, forEachEntry, hashCode, remove, remove, removeAll, retainAll, setCount, setCount, spliterator, toString
-
Methods inherited from interface com.google.common.collect.SortedMultiset
entrySet, iterator
-
-
-
-
Field Detail
-
forward
private final transient ImmutableSortedMultiset<E> forward
-
-
Constructor Detail
-
DescendingImmutableSortedMultiset
DescendingImmutableSortedMultiset(ImmutableSortedMultiset<E> forward)
-
-
Method Detail
-
count
public int count(java.lang.Object element)
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
-
firstEntry
public Multiset.Entry<E> firstEntry()
Description copied from interface:SortedMultiset
Returns the entry of the first element in this multiset, ornull
if this multiset is empty.
-
lastEntry
public Multiset.Entry<E> lastEntry()
Description copied from interface:SortedMultiset
Returns the entry of the last element in this multiset, ornull
if this multiset is empty.
-
size
public int size()
Description copied from interface:Multiset
Returns the total number of all occurrences of all elements in this multiset.Note: this method does not return the number of distinct elements in the multiset, which is given by
entrySet().size()
.
-
elementSet
public ImmutableSortedSet<E> elementSet()
Description copied from interface:Multiset
Returns the set of distinct elements contained in this multiset. The element set is backed by the same data as the multiset, so any change to either is immediately reflected in the other. The order of the elements in the element set is unspecified.If the element set supports any removal operations, these necessarily cause all occurrences of the removed element(s) to be removed from the multiset. Implementations are not expected to support the add operations, although this is possible.
A common use for the element set is to find the number of distinct elements in the multiset:
elementSet().size()
.- Specified by:
elementSet
in interfaceMultiset<E>
- Specified by:
elementSet
in interfaceSortedMultiset<E>
- Specified by:
elementSet
in interfaceSortedMultisetBridge<E>
- Specified by:
elementSet
in classImmutableSortedMultiset<E>
- Returns:
- a view of the set of distinct elements in this multiset
-
getEntry
Multiset.Entry<E> getEntry(int index)
- Specified by:
getEntry
in classImmutableMultiset<E>
-
descendingMultiset
public ImmutableSortedMultiset<E> descendingMultiset()
Description copied from interface:SortedMultiset
Returns a descending view of this multiset. Modifications made to either map will be reflected in the other.- Specified by:
descendingMultiset
in interfaceSortedMultiset<E>
- Overrides:
descendingMultiset
in classImmutableSortedMultiset<E>
-
headMultiset
public ImmutableSortedMultiset<E> headMultiset(E upperBound, BoundType boundType)
Description copied from interface:SortedMultiset
Returns a view of this multiset restricted to the elements less thanupperBound
, optionally includingupperBound
itself. The returned multiset is a view of this multiset, so changes to one will be reflected in the other. The returned multiset supports all operations that this multiset supports.The returned multiset will throw an
IllegalArgumentException
on attempts to add elements outside its range.- Specified by:
headMultiset
in interfaceSortedMultiset<E>
- Specified by:
headMultiset
in classImmutableSortedMultiset<E>
-
tailMultiset
public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType)
Description copied from interface:SortedMultiset
Returns a view of this multiset restricted to the elements greater thanlowerBound
, optionally includinglowerBound
itself. The returned multiset is a view of this multiset, so changes to one will be reflected in the other. The returned multiset supports all operations that this multiset supports.The returned multiset will throw an
IllegalArgumentException
on attempts to add elements outside its range.- Specified by:
tailMultiset
in interfaceSortedMultiset<E>
- Specified by:
tailMultiset
in classImmutableSortedMultiset<E>
-
isPartialView
boolean isPartialView()
Description copied from class:ImmutableCollection
Returnstrue
if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods. This is generally used to determine whethercopyOf
implementations should make an explicit copy to avoid memory leaks.- Specified by:
isPartialView
in classImmutableCollection<E>
-
-