SortedMultiset whose contents will never change, with many other important properties
detailed at ImmutableCollection.Warning
as with any sorted collection, you are strongly advised not to use a Comparator or Comparable type whose comparison behavior is inconsistent with
equals. That is, a.compareTo(b) or comparator.compare(a, b) should equal zero
if and only if a.equals(b). If this advice is not followed, the resulting
collection will not correctly obey its specification.
See the Guava User Guide article on immutable collections.
| Modifier and Type | Class and Description |
|---|---|
| public static class | ImmutableSortedMultiset.Builder<E>
A builder for creating immutable multiset instances, especially |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv transient ImmutableSortedMultiset |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final Comparator | comparator()
Implements com. Ordering#natural() if the natural
ordering of the elements is used.
|
| public static <E extends Comparable | copyOf(E[] elements)
Hides com. |
| public static <E> ImmutableSortedMultiset | |
| public static <E> ImmutableSortedMultiset | |
| public static <E> ImmutableSortedMultiset | copyOf(Comparator<? super E> comparator, Iterator<? extends E> elements)
Returns an immutable sorted multiset containing the given elements sorted by the given |
| public static <E> ImmutableSortedMultiset | copyOf(Comparator<? super E> comparator, Iterable<? extends E> elements)
Returns an immutable sorted multiset containing the given elements sorted by the given |
| public static <E> ImmutableSortedMultiset | copyOfSorted(SortedMultiset<E> sortedMultiset)
Returns an immutable sorted multiset containing the elements of a sorted multiset, sorted by
the same |
| private static <E> ImmutableSortedMultiset | |
| public ImmutableSortedMultiset | descendingMultiset()
Implements com. |
| public abstract ImmutableSortedSet | elementSet()
Redeclares com. Implements abstract com. NavigableSet view of the distinct elements in this multiset.
|
| pack-priv static <E> ImmutableSortedMultiset | |
| public abstract ImmutableSortedMultiset | headMultiset(E upperBound, BoundType boundType)
Redeclares com. upperBound,
optionally including upperBound itself.
|
| public static <E extends Comparable | naturalOrder()
Returns a builder that creates immutable sorted multisets whose elements are ordered by their natural ordering. |
| public static <E> ImmutableSortedMultiset | of()
Returns the empty immutable sorted multiset.
|
| public static <E extends Comparable | of(E element)
Hides com. |
| public static <E extends Comparable | of(E e1, E e2)
Hides com. |
| public static <E extends Comparable | of(E e1, E e2, E e3)
Hides com. |
| public static <E extends Comparable | of(E e1, E e2, E e3, E e4)
Hides com. |
| public static <E extends Comparable | of(E e1, E e2, E e3, E e4, E e5)
Hides com. |
| public static <E extends Comparable | of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining)
Hides com. |
| public static <E> ImmutableSortedMultiset. | orderedBy(Comparator<E> comparator)
Returns a builder that creates immutable sorted multisets with an explicit comparator. |
| public final Multiset. | pollFirstEntry()
Implements com.
Deprecated
Unsupported operation.
Returns and removes the entry associated with the lowest element in this multiset, or returns
null if this multiset is empty.
|
| public final Multiset. | pollLastEntry()
Implements com.
Deprecated
Unsupported operation.
Returns and removes the entry associated with the greatest element in this multiset, or returns
null if this multiset is empty.
|
| private void | |
| public static <E extends Comparable | reverseOrder()
Returns a builder that creates immutable sorted multisets whose elements are ordered by the reverse of their natural ordering. |
| public ImmutableSortedMultiset | subMultiset(E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType)
Implements com. lowerBound and upperBound.
|
| public abstract ImmutableSortedMultiset | tailMultiset(E lowerBound, BoundType boundType)
Redeclares com. lowerBound,
optionally including lowerBound itself.
|
| public static <E> Collector | toImmutableSortedMultiset(Comparator<? super E> comparator)
Returns a |
| public static <T extends @Nullable Object, E> Collector | toImmutableSortedMultiset(Comparator<? super E> comparator, Function<? super T, ? extends E> elementFunction, ToIntFunction<? super T> countFunction)
Returns a |
| pack-priv Object |
| descendingMultiset | back to summary |
|---|---|
| pack-priv transient ImmutableSortedMultiset<E> descendingMultiset
| |
| ImmutableSortedMultiset | back to summary |
|---|---|
| pack-priv ImmutableSortedMultiset() | |
| comparator | back to summary |
|---|---|
| public final Comparator Implements com. Doc from com. Returns the comparator that orders this multiset, or
| |
| copyOf | back to summary |
|---|---|
| public static <E extends Comparable Hides com. Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.
| |
| copyOf | back to summary |
|---|---|
| public static <E> ImmutableSortedMultiset Hides com. Returns an immutable sorted multiset containing the given elements sorted by their natural
ordering. To create a copy of a Note that if Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change. This method is not type-safe, as it may be called on elements that are not mutually comparable.
| |
| copyOf | back to summary |
|---|---|
| public static <E> ImmutableSortedMultiset Hides com. Returns an immutable sorted multiset containing the given elements sorted by their natural ordering. This method is not type-safe, as it may be called on elements that are not mutually comparable.
| |
| copyOf | back to summary |
|---|---|
| public static <E> ImmutableSortedMultiset Returns an immutable sorted multiset containing the given elements sorted by the given
| |
| copyOf | back to summary |
|---|---|
| public static <E> ImmutableSortedMultiset Returns an immutable sorted multiset containing the given elements sorted by the given Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change.
| |
| copyOfSorted | back to summary |
|---|---|
| public static <E> ImmutableSortedMultiset Returns an immutable sorted multiset containing the elements of a sorted multiset, sorted by
the same Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change. This method is safe to use even when
| |
| copyOfSortedEntries | back to summary |
|---|---|
| private static <E> ImmutableSortedMultiset | |
| descendingMultiset | back to summary |
|---|---|
| public ImmutableSortedMultiset Implements com. Doc from com. Returns a descending view of this multiset. Modifications made to either map will be reflected in the other.
| |
| elementSet | back to summary |
|---|---|
| public abstract ImmutableSortedSet Redeclares com. Implements abstract com. Doc from com. Returns a
| |
| emptyMultiset | back to summary |
|---|---|
pack-priv static <E> ImmutableSortedMultiset
| |
| headMultiset | back to summary |
|---|---|
| public abstract ImmutableSortedMultiset Redeclares com. Doc from com. Returns a view of this multiset restricted to the elements less than The returned multiset will throw an
| |
| naturalOrder | back to summary |
|---|---|
| public static <E extends Comparable Returns a builder that creates immutable sorted multisets whose elements are ordered by their
natural ordering. The sorted multisets use Note the type parameter | |
| of | back to summary |
|---|---|
| public static <E> ImmutableSortedMultiset Hides com. Returns the empty immutable sorted multiset. Performance note: the instance returned is a singleton.
| |
| of | back to summary |
|---|---|
| public static <E extends Comparable Hides com. Returns an immutable sorted multiset containing a single element. | |
| of | back to summary |
|---|---|
| public static <E extends Comparable Hides com. Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.
| |
| of | back to summary |
|---|---|
| public static <E extends Comparable Hides com. Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.
| |
| of | back to summary |
|---|---|
| public static <E extends Comparable Hides com. Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.
| |
| of | back to summary |
|---|---|
| public static <E extends Comparable Hides com. Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.
| |
| of | back to summary |
|---|---|
| public static <E extends Comparable Hides com. Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.
| |
| orderedBy | back to summary |
|---|---|
| public static <E> ImmutableSortedMultiset. Returns a builder that creates immutable sorted multisets with an explicit comparator. If the
comparator has a more general type than the set being generated, such as creating a
| |
| pollFirstEntry | back to summary |
|---|---|
| public final Multiset. Implements com. Doc from com. Deprecated Unsupported operation. Returns and removes the entry associated with the lowest element in this multiset, or returns
This implementation is guaranteed to throw an
| |
| pollLastEntry | back to summary |
|---|---|
| public final Multiset. Implements com. Doc from com. Deprecated Unsupported operation. Returns and removes the entry associated with the greatest element in this multiset, or returns
This implementation is guaranteed to throw an
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream stream) throws InvalidObjectException Hides com.
| |
| reverseOrder | back to summary |
|---|---|
| public static <E extends Comparable Returns a builder that creates immutable sorted multisets whose elements are ordered by the reverse of their natural ordering. Note the type parameter | |
| subMultiset | back to summary |
|---|---|
| public ImmutableSortedMultiset Implements com. Doc from com. Returns a view of this multiset restricted to the range between The returned multiset will throw an This method is equivalent to
| |
| tailMultiset | back to summary |
|---|---|
| public abstract ImmutableSortedMultiset Redeclares com. Doc from com. Returns a view of this multiset restricted to the elements greater than The returned multiset will throw an
| |
| toImmutableSortedMultiset | back to summary |
|---|---|
| public static <E> Collector Returns a Warning
| |
| toImmutableSortedMultiset | back to summary |
|---|---|
| public static <T extends @Nullable Object, E> Collector Returns a If the mapped elements contain duplicates (according to
| |
| writeReplace | back to summary |
|---|---|
| pack-priv Object writeReplace() Overrides com.
| |
public static final
multisets ("constant multisets"). Example:
public static final ImmutableSortedMultiset<Bean> BEANS =
new ImmutableSortedMultiset.Builder<Bean>(colorComparator())
.addCopies(Bean.COCOA, 4)
.addCopies(Bean.GARDEN, 6)
.addCopies(Bean.RED, 8)
.addCopies(Bean.BLACK_EYED, 10)
.build();
Builder instances can be reused; it is safe to call build multiple times to build
multiple multisets in series.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public ImmutableSortedMultiset. | Returns: thisBuilder objectthe element to add element)Overrides com. element to the ImmutableSortedMultiset.
|
| public ImmutableSortedMultiset. | Returns: thisBuilder objectthe elements to add elements)Overrides com. elements to the ImmutableSortedMultiset.
|
| public ImmutableSortedMultiset. | Returns: thisBuilder objectthe elements)Iterable to add to the ImmutableSortedMultisetOverrides com. elements to the ImmutableSortedMultiset.
|
| public ImmutableSortedMultiset. | Returns: thisBuilder objectthe elements to add to the elements)ImmutableSortedMultisetOverrides com. elements to the ImmutableSortedMultiset.
|
| public ImmutableSortedMultiset. | Returns: thisBuilder objectthe element to add element, int the number of occurrences of the element to add. May be zero, in which
case no change will be made. occurrences)Overrides com. ImmutableSortedMultiset.
|
| public ImmutableSortedMultiset | build()
Overrides com. ImmutableSortedMultiset based on the contents of the Builder.
|
| public ImmutableSortedMultiset. | Returns: thisBuilder objectthe element to add or remove occurrences of element, int the desired count of the element in this multiset count)Overrides com. |
| Builder | back to summary |
|---|---|
| public Builder(Comparator<? super E> comparator) Creates a new builder. The returned builder is equivalent to the builder generated by | |
| add | back to summary |
|---|---|
| public ImmutableSortedMultiset. Overrides com. Adds
| |
| add | back to summary |
|---|---|
| public ImmutableSortedMultiset. Overrides com. Adds each element of
| |
| addAll | back to summary |
|---|---|
| public ImmutableSortedMultiset. Overrides com. Adds each element of
| |
| addAll | back to summary |
|---|---|
| public ImmutableSortedMultiset. Overrides com. Adds each element of
| |
| addCopies | back to summary |
|---|---|
| public ImmutableSortedMultiset. Overrides com. Adds a number of occurrences of an element to this
| |
| build | back to summary |
|---|---|
| public ImmutableSortedMultiset Overrides com. Returns a newly-created
| |
| setCount | back to summary |
|---|---|
| public ImmutableSortedMultiset. Overrides com. Adds or removes the necessary occurrences of an element such that the element attains the desired count.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Comparator | |
| pack-priv final int[] | |
| pack-priv final E[] |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Object |
| comparator | back to summary |
|---|---|
| pack-priv final Comparator<? super E> comparator | |
| counts | back to summary |
|---|---|
| pack-priv final int[] counts | |
| elements | back to summary |
|---|---|
| pack-priv final E[] elements | |
| SerializedForm | back to summary |
|---|---|
pack-priv SerializedForm(SortedMultiset<E> multiset)
| |
| readResolve | back to summary |
|---|---|
| pack-priv Object readResolve() | |