Top Description Inners Constructors Methods
com.google.common.collect

public abstract Class ForwardingSortedMultiset<E extends @Nullable Object>

extends ForwardingMultiset<E extends @Nullable Object>
implements SortedMultiset<E extends @Nullable Object>
Class Inheritance
All Implemented Interfaces
com.google.common.collect.SortedMultiset, com.google.common.collect.SortedIterable, java.lang.Iterable, com.google.common.collect.SortedMultisetBridge, com.google.common.collect.Multiset, java.util.Collection
Annotations
@GwtCompatible
emulated:true
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.GwtCompatible, java.util.Comparator, .Iterator, .NavigableSet, javax.annotation.CheckForNull, org.checkerframework.checker.nullness.qual.Nullable

A sorted multiset which forwards all its method calls to another sorted multiset. Subclasses should override one or more methods to modify the behavior of the backing multiset as desired per the decorator pattern.

Warning

The methods of ForwardingSortedMultiset forward indiscriminately to the methods of the delegate. For example, overriding add(Object, int) alone will not change the behavior of add(Object), which can lead to unexpected behavior. In this case, you should override add(Object) as well, either providing your own implementation, or delegating to the provided standardAdd method.

default method warning: This class does not forward calls to default methods. Instead, it inherits their default implementations. When those implementations invoke methods, they invoke methods on the ForwardingSortedMultiset.

The standard methods and any collection views they return are not guaranteed to be thread-safe, even when all of the methods that they depend on are thread-safe.

Author
Louis Wasserman
Since
15.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract class
ForwardingSortedMultiset.StandardDescendingMultiset

A skeleton implementation of a descending multiset view.

protected class

Constructor Summary

AccessConstructor and Description
protected
ForwardingSortedMultiset()

Constructor for use by subclasses.

Method Summary

Modifier and TypeMethod and Description
public Comparator<? super E>
comparator()

Implements com.google.common.collect.SortedMultiset.comparator.

Returns the comparator that orders this multiset, or Ordering#natural() if the natural ordering of the elements is used.
protected abstract SortedMultiset<E>
delegate()

Implements abstract com.google.common.collect.ForwardingMultiset.delegate.

Returns the backing delegate instance that methods are forwarded to.
public SortedMultiset<E>
descendingMultiset()

Implements com.google.common.collect.SortedMultiset.descendingMultiset.

Returns a descending view of this multiset.
public NavigableSet<E>
public Multiset.Entry<E>
firstEntry()

Implements com.google.common.collect.SortedMultiset.firstEntry.

Returns the entry of the first element in this multiset, or null if this multiset is empty.
public SortedMultiset<E>
headMultiset(E upperBound, BoundType boundType)

Implements com.google.common.collect.SortedMultiset.headMultiset.

Returns a view of this multiset restricted to the elements less than upperBound, optionally including upperBound itself.
public Multiset.Entry<E>
lastEntry()

Implements com.google.common.collect.SortedMultiset.lastEntry.

Returns the entry of the last element in this multiset, or null if this multiset is empty.
public Multiset.Entry<E>
pollFirstEntry()

Implements com.google.common.collect.SortedMultiset.pollFirstEntry.

Returns and removes the entry associated with the lowest element in this multiset, or returns null if this multiset is empty.
public Multiset.Entry<E>
pollLastEntry()

Implements com.google.common.collect.SortedMultiset.pollLastEntry.

Returns and removes the entry associated with the greatest element in this multiset, or returns null if this multiset is empty.
protected Multiset.Entry<E>
standardFirstEntry()

A sensible definition of firstEntry() in terms of entrySet().iterator().

protected Multiset.Entry<E>
standardLastEntry()

A sensible definition of lastEntry() in terms of descendingMultiset().entrySet().iterator().

protected Multiset.Entry<E>
standardPollFirstEntry()

A sensible definition of pollFirstEntry() in terms of entrySet().iterator().

protected Multiset.Entry<E>
standardPollLastEntry()

A sensible definition of pollLastEntry() in terms of descendingMultiset().entrySet().iterator().

protected SortedMultiset<E>
standardSubMultiset(E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType)

A sensible definition of subMultiset(Object, BoundType, Object, BoundType) in terms of headMultiset and tailMultiset.

public SortedMultiset<E>
subMultiset(E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType)

Implements com.google.common.collect.SortedMultiset.subMultiset.

Returns a view of this multiset restricted to the range between lowerBound and upperBound.
public SortedMultiset<E>
tailMultiset(E lowerBound, BoundType boundType)

Implements com.google.common.collect.SortedMultiset.tailMultiset.

Returns a view of this multiset restricted to the elements greater than lowerBound, optionally including lowerBound itself.
Inherited from com.google.common.collect.ForwardingMultiset:
addcountentrySetequalshashCoderemovesetCountsetCountstandardAddstandardAddAllstandardClearstandardContainsstandardCountstandardEqualsstandardHashCodestandardIteratorstandardRemovestandardRemoveAllstandardRetainAllstandardSetCountstandardSetCountstandardSizestandardToString

Constructor Detail

ForwardingSortedMultisetback to summary
protected ForwardingSortedMultiset()

Constructor for use by subclasses.

Method Detail

comparatorback to summary
public Comparator<? super E> comparator()

Implements com.google.common.collect.SortedMultiset.comparator.

Doc from com.google.common.collect.SortedMultiset.comparator.

Returns the comparator that orders this multiset, or Ordering#natural() if the natural ordering of the elements is used.

Annotations
@Override
delegateback to summary
protected abstract SortedMultiset<E> delegate()

Implements abstract com.google.common.collect.ForwardingMultiset.delegate.

Doc from com.google.common.collect.ForwardingObject.delegate.

Returns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such as ForwardingSet#delegate. Concrete subclasses override this method to supply the instance being decorated.

Annotations
@Override
descendingMultisetback to summary
public SortedMultiset<E> descendingMultiset()

Implements com.google.common.collect.SortedMultiset.descendingMultiset.

Doc from com.google.common.collect.SortedMultiset.descendingMultiset.

Returns a descending view of this multiset. Modifications made to either map will be reflected in the other.

Annotations
@Override
elementSetback to summary
public NavigableSet<E> elementSet()

Overrides com.google.common.collect.ForwardingMultiset.elementSet.

Implements com.google.common.collect.SortedMultiset.elementSet, com.google.common.collect.Multiset.elementSet.

Doc from com.google.common.collect.SortedMultiset.elementSet.

Returns a NavigableSet view of the distinct elements in this multiset.

Returns:NavigableSet<E>

Doc from com.google.common.collect.Multiset.elementSet.

a view of the set of distinct elements in this multiset

Annotations
@Override
firstEntryback to summary
public Multiset.Entry<E> firstEntry()

Implements com.google.common.collect.SortedMultiset.firstEntry.

Doc from com.google.common.collect.SortedMultiset.firstEntry.

Returns the entry of the first element in this multiset, or null if this multiset is empty.

Annotations
@Override
@CheckForNull
headMultisetback to summary
public SortedMultiset<E> headMultiset(E upperBound, BoundType boundType)

Implements com.google.common.collect.SortedMultiset.headMultiset.

Doc from com.google.common.collect.SortedMultiset.headMultiset.

Returns a view of this multiset restricted to the elements less than upperBound, optionally including upperBound 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.

Annotations
@Override
lastEntryback to summary
public Multiset.Entry<E> lastEntry()

Implements com.google.common.collect.SortedMultiset.lastEntry.

Doc from com.google.common.collect.SortedMultiset.lastEntry.

Returns the entry of the last element in this multiset, or null if this multiset is empty.

Annotations
@Override
@CheckForNull
pollFirstEntryback to summary
public Multiset.Entry<E> pollFirstEntry()

Implements com.google.common.collect.SortedMultiset.pollFirstEntry.

Doc from com.google.common.collect.SortedMultiset.pollFirstEntry.

Returns and removes the entry associated with the lowest element in this multiset, or returns null if this multiset is empty.

Annotations
@Override
@CheckForNull
pollLastEntryback to summary
public Multiset.Entry<E> pollLastEntry()

Implements com.google.common.collect.SortedMultiset.pollLastEntry.

Doc from com.google.common.collect.SortedMultiset.pollLastEntry.

Returns and removes the entry associated with the greatest element in this multiset, or returns null if this multiset is empty.

Annotations
@Override
@CheckForNull
standardFirstEntryback to summary
protected Multiset.Entry<E> standardFirstEntry()

A sensible definition of firstEntry() in terms of entrySet().iterator().

If you override entrySet(), you may wish to override firstEntry() to forward to this implementation.

Annotations
@CheckForNull
standardLastEntryback to summary
protected Multiset.Entry<E> standardLastEntry()

A sensible definition of lastEntry() in terms of descendingMultiset().entrySet().iterator().

If you override descendingMultiset or entrySet(), you may wish to override firstEntry() to forward to this implementation.

Annotations
@CheckForNull
standardPollFirstEntryback to summary
protected Multiset.Entry<E> standardPollFirstEntry()

A sensible definition of pollFirstEntry() in terms of entrySet().iterator().

If you override entrySet(), you may wish to override pollFirstEntry() to forward to this implementation.

Annotations
@CheckForNull
standardPollLastEntryback to summary
protected Multiset.Entry<E> standardPollLastEntry()

A sensible definition of pollLastEntry() in terms of descendingMultiset().entrySet().iterator().

If you override descendingMultiset() or entrySet(), you may wish to override pollLastEntry() to forward to this implementation.

Annotations
@CheckForNull
standardSubMultisetback to summary
protected SortedMultiset<E> standardSubMultiset(E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType)

A sensible definition of subMultiset(Object, BoundType, Object, BoundType) in terms of headMultiset and tailMultiset.

If you override either of these methods, you may wish to override subMultiset(Object, BoundType, Object, BoundType) to forward to this implementation.

subMultisetback to summary
public SortedMultiset<E> subMultiset(E lowerBound, BoundType lowerBoundType, E upperBound, BoundType upperBoundType)

Implements com.google.common.collect.SortedMultiset.subMultiset.

Doc from com.google.common.collect.SortedMultiset.subMultiset.

Returns a view of this multiset restricted to the range between lowerBound and upperBound. 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.

This method is equivalent to tailMultiset(lowerBound, lowerBoundType).headMultiset(upperBound, upperBoundType).

Annotations
@Override
tailMultisetback to summary
public SortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType)

Implements com.google.common.collect.SortedMultiset.tailMultiset.

Doc from com.google.common.collect.SortedMultiset.tailMultiset.

Returns a view of this multiset restricted to the elements greater than lowerBound, optionally including lowerBound 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.

Annotations
@Override
com.google.common.collect back to summary

protected abstract Class ForwardingSortedMultiset.StandardDescendingMultiset

extends DescendingMultiset<E extends @Nullable Object>
Class Inheritance

A skeleton implementation of a descending multiset view. Normally, descendingMultiset() will not reflect any changes you make to the behavior of methods such as add(Object) or pollFirstEntry. This skeleton implementation correctly delegates each of its operations to the appropriate methods of this ForwardingSortedMultiset.

In many cases, you may wish to override descendingMultiset() to return an instance of a subclass of StandardDescendingMultiset.

Since
15.0

Constructor Summary

AccessConstructor and Description
public
StandardDescendingMultiset()

Constructor for use by subclasses.

Method Summary

Modifier and TypeMethod and Description
pack-priv SortedMultiset<E>
Inherited from com.google.common.collect.DescendingMultiset:
comparatorcreateEntrySetdelegatedescendingMultisetelementSetentryIteratorentrySetfirstEntryheadMultisetiteratorlastEntrypollFirstEntrypollLastEntrysubMultisettailMultisettoArraytoArraytoString

Constructor Detail

StandardDescendingMultisetback to summary
public StandardDescendingMultiset()

Constructor for use by subclasses.

Method Detail

forwardMultisetback to summary
pack-priv SortedMultiset<E> forwardMultiset()

Implements abstract com.google.common.collect.DescendingMultiset.forwardMultiset.

Annotations
@Override
com.google.common.collect back to summary

protected Class ForwardingSortedMultiset.StandardElementSet

extends SortedMultisets.NavigableElementSet<E extends @Nullable Object>
Class Inheritance

A sensible implementation of SortedMultiset#elementSet in terms of the following methods: SortedMultiset#clear, SortedMultiset#comparator, SortedMultiset#contains, SortedMultiset#containsAll, SortedMultiset#count, SortedMultiset#firstEntry SortedMultiset#headMultiset, SortedMultiset#isEmpty, SortedMultiset#lastEntry, SortedMultiset#subMultiset, SortedMultiset#tailMultiset, the size() and iterator() methods of SortedMultiset#entrySet, and SortedMultiset#remove(Object, int). In many situations, you may wish to override SortedMultiset#elementSet to forward to this implementation or a subclass thereof.
Since
15.0

Constructor Summary

AccessConstructor and Description
public
StandardElementSet()

Constructor for use by subclasses.

Method Summary

Inherited from com.google.common.collect.SortedMultisets.NavigableElementSet:
ceilingdescendingIteratordescendingSetfloorheadSethigherlowerpollFirstpollLastsubSettailSet

Constructor Detail

StandardElementSetback to summary
public StandardElementSet()

Constructor for use by subclasses.