Package com.google.common.collect
Class RegularImmutableSortedMultiset<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- com.google.common.collect.ImmutableCollection<E>
-
- com.google.common.collect.ImmutableMultiset<E>
-
- com.google.common.collect.ImmutableSortedMultisetFauxverideShim<E>
-
- com.google.common.collect.ImmutableSortedMultiset<E>
-
- com.google.common.collect.RegularImmutableSortedMultiset<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 RegularImmutableSortedMultiset<E> extends ImmutableSortedMultiset<E>
An immutable sorted multiset with one or more distinct elements.
-
-
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.EntrySetSerializedForm<E>
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableCollection
ImmutableCollection.ArrayBasedBuilder<E>
-
Nested classes/interfaces inherited from interface com.google.common.collect.Multiset
Multiset.Entry<E>
-
-
Field Summary
Fields Modifier and Type Field Description private long[]cumulativeCountsprivate RegularImmutableSortedSet<E>elementSetprivate intlength(package private) static ImmutableSortedMultiset<java.lang.Comparable>NATURAL_EMPTY_MULTISETprivate intoffsetprivate static long[]ZERO_CUMULATIVE_COUNTS-
Fields inherited from class com.google.common.collect.ImmutableSortedMultiset
descendingMultiset
-
-
Constructor Summary
Constructors Constructor Description RegularImmutableSortedMultiset(RegularImmutableSortedSet<E> elementSet, long[] cumulativeCounts, int offset, int length)RegularImmutableSortedMultiset(java.util.Comparator<? super E> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcount(java.lang.Object element)Returns the number of occurrences of an element in this multiset (the count of the element).ImmutableSortedSet<E>elementSet()Returns aNavigableSetview of the distinct elements in this multiset.Multiset.Entry<E>firstEntry()Returns the entry of the first element in this multiset, ornullif this multiset is empty.private intgetCount(int index)(package private) Multiset.Entry<E>getEntry(int index)(package private) ImmutableSortedMultiset<E>getSubMultiset(int from, int to)ImmutableSortedMultiset<E>headMultiset(E upperBound, BoundType boundType)Returns a view of this multiset restricted to the elements less thanupperBound, optionally includingupperBounditself.(package private) booleanisPartialView()Returnstrueif 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, ornullif this multiset is empty.intsize()ImmutableSortedMultiset<E>tailMultiset(E lowerBound, BoundType boundType)Returns a view of this multiset restricted to the elements greater thanlowerBound, optionally includinglowerBounditself.-
Methods inherited from class com.google.common.collect.ImmutableSortedMultiset
comparator, copyOf, copyOf, copyOf, copyOf, copyOf, copyOfSorted, descendingMultiset, emptyMultiset, naturalOrder, of, of, of, of, of, of, of, orderedBy, pollFirstEntry, pollLastEntry, reverseOrder, subMultiset, writeReplace
-
Methods inherited from class com.google.common.collect.ImmutableSortedMultisetFauxverideShim
builder, copyOf, of, of, of, of, of, of
-
Methods inherited from class com.google.common.collect.ImmutableMultiset
add, asList, contains, copyFromEntries, copyIntoArray, createAsList, entrySet, equals, hashCode, iterator, remove, setCount, setCount, toString
-
Methods inherited from class com.google.common.collect.ImmutableCollection
add, addAll, clear, remove, removeAll, retainAll, 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, spliterator, stream, toArray, toArray, toArray
-
Methods inherited from interface com.google.common.collect.Multiset
add, add, contains, containsAll, equals, hashCode, remove, remove, removeAll, retainAll, setCount, setCount, toString
-
Methods inherited from interface com.google.common.collect.SortedMultiset
entrySet, iterator
-
-
-
-
Field Detail
-
ZERO_CUMULATIVE_COUNTS
private static final long[] ZERO_CUMULATIVE_COUNTS
-
NATURAL_EMPTY_MULTISET
static final ImmutableSortedMultiset<java.lang.Comparable> NATURAL_EMPTY_MULTISET
-
elementSet
private final transient RegularImmutableSortedSet<E> elementSet
-
cumulativeCounts
private final transient long[] cumulativeCounts
-
offset
private final transient int offset
-
length
private final transient int length
-
-
Constructor Detail
-
RegularImmutableSortedMultiset
RegularImmutableSortedMultiset(java.util.Comparator<? super E> comparator)
-
RegularImmutableSortedMultiset
RegularImmutableSortedMultiset(RegularImmutableSortedSet<E> elementSet, long[] cumulativeCounts, int offset, int length)
-
-
Method Detail
-
getCount
private int getCount(int index)
-
getEntry
Multiset.Entry<E> getEntry(int index)
- Specified by:
getEntryin classImmutableMultiset<E>
-
firstEntry
public Multiset.Entry<E> firstEntry()
Description copied from interface:SortedMultisetReturns the entry of the first element in this multiset, ornullif this multiset is empty.
-
lastEntry
public Multiset.Entry<E> lastEntry()
Description copied from interface:SortedMultisetReturns the entry of the last element in this multiset, ornullif this multiset is empty.
-
count
public int count(@Nullable java.lang.Object element)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
-
size
public int size()
-
elementSet
public ImmutableSortedSet<E> elementSet()
Description copied from interface:SortedMultisetReturns aNavigableSetview of the distinct elements in this multiset.- Specified by:
elementSetin interfaceMultiset<E>- Specified by:
elementSetin interfaceSortedMultiset<E>- Specified by:
elementSetin interfaceSortedMultisetBridge<E>- Specified by:
elementSetin classImmutableSortedMultiset<E>- Returns:
- a view of the set of distinct elements in this multiset
-
headMultiset
public ImmutableSortedMultiset<E> headMultiset(E upperBound, BoundType boundType)
Description copied from interface:SortedMultisetReturns a view of this multiset restricted to the elements less thanupperBound, optionally includingupperBounditself. 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
IllegalArgumentExceptionon attempts to add elements outside its range.- Specified by:
headMultisetin interfaceSortedMultiset<E>- Specified by:
headMultisetin classImmutableSortedMultiset<E>
-
tailMultiset
public ImmutableSortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType)
Description copied from interface:SortedMultisetReturns a view of this multiset restricted to the elements greater thanlowerBound, optionally includinglowerBounditself. 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
IllegalArgumentExceptionon attempts to add elements outside its range.- Specified by:
tailMultisetin interfaceSortedMultiset<E>- Specified by:
tailMultisetin classImmutableSortedMultiset<E>
-
getSubMultiset
ImmutableSortedMultiset<E> getSubMultiset(int from, int to)
-
isPartialView
boolean isPartialView()
Description copied from class:ImmutableCollectionReturnstrueif 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 whethercopyOfimplementations should make an explicit copy to avoid memory leaks.- Specified by:
isPartialViewin classImmutableCollection<E>
-
-