Top Description Constructors Methods
com.google.common.collect

public abstract Class ForwardingSortedSet<E extends @Nullable Object>

extends ForwardingSet<E extends @Nullable Object>
implements SortedSet<E extends @Nullable Object>
Class Inheritance
All Implemented Interfaces
java.util.SortedSet, java.util.SequencedSet, java.util.Set, java.util.Collection, java.lang.Iterable, java.util.SequencedCollection
Known Direct Subclasses
com.google.common.collect.Sets.UnmodifiableNavigableSet, com.google.common.collect.ForwardingNavigableSet
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.collect.ForwardingSortedMap.unsafeCompare

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

Warning

The methods of ForwardingSortedSet forward indiscriminately to the methods of the delegate. For example, overriding add alone will not change the behavior of addAll, which can lead to unexpected behavior. In this case, you should override addAll as well, either providing your own implementation, or delegating to the provided standardAddAll 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 ForwardingSortedSet.

Each of the standard methods, where appropriate, uses the set's comparator (or the natural ordering of the elements, if there is no comparator) to test element equality. As a result, if the comparator is not consistent with equals, some of the standard implementations may violate the Set contract.

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

Authors
Mike Bostock, Louis Wasserman
Since
2.0

Constructor Summary

AccessConstructor and Description
protected
ForwardingSortedSet()

Constructor for use by subclasses.

Method Summary

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

Implements java.util.SortedSet.comparator.

Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.
protected abstract SortedSet<E>
delegate()

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

Returns the backing delegate instance that methods are forwarded to.
public E
first()

Implements java.util.SortedSet.first.

Returns the first (lowest) element currently in this set.
public SortedSet<E>
headSet(E
high endpoint (exclusive) of the returned set
toElement
)

Implements java.util.SortedSet.headSet.

Returns a view of the portion of this set whose elements are strictly less than toElement.
public E
last()

Implements java.util.SortedSet.last.

Returns the last (highest) element currently in this set.
protected boolean
standardContains(Object object)

Overrides com.google.common.collect.ForwardingCollection.standardContains.

A sensible definition of contains in terms of the first() method of tailSet.
protected boolean
standardRemove(Object object)

Overrides com.google.common.collect.ForwardingCollection.standardRemove.

A sensible definition of remove in terms of the iterator() method of tailSet.
protected SortedSet<E>
standardSubSet(E fromElement, E toElement)

A sensible default implementation of subSet(Object, Object) in terms of headSet(Object) and tailSet(Object).

public SortedSet<E>
subSet(E
low endpoint (inclusive) of the returned set
fromElement
,
E
high endpoint (exclusive) of the returned set
toElement
)

Implements java.util.SortedSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
public SortedSet<E>
tailSet(E
low endpoint (inclusive) of the returned set
fromElement
)

Implements java.util.SortedSet.tailSet.

Returns a view of the portion of this set whose elements are greater than or equal to fromElement.
Inherited from com.google.common.collect.ForwardingSet:
equalshashCodestandardEqualsstandardHashCodestandardRemoveAll

Constructor Detail

ForwardingSortedSetback to summary
protected ForwardingSortedSet()

Constructor for use by subclasses.

Method Detail

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

Implements java.util.SortedSet.comparator.

Doc from java.util.SortedSet.comparator.

Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.

Returns:Comparator<? super E>

the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements

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

Implements abstract com.google.common.collect.ForwardingSet.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
firstback to summary
public E first()

Implements java.util.SortedSet.first.

Doc from java.util.SortedSet.first.

Returns the first (lowest) element currently in this set.

Returns:E

the first (lowest) element currently in this set

Annotations
@Override
@ParametricNullness
headSetback to summary
public SortedSet<E> headSet(E toElement)

Implements java.util.SortedSet.headSet.

Doc from java.util.SortedSet.headSet.

Returns a view of the portion of this set whose elements are strictly less than toElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
toElement:E

high endpoint (exclusive) of the returned set

Returns:SortedSet<E>

a view of the portion of this set whose elements are strictly less than toElement

Annotations
@Override
lastback to summary
public E last()

Implements java.util.SortedSet.last.

Doc from java.util.SortedSet.last.

Returns the last (highest) element currently in this set.

Returns:E

the last (highest) element currently in this set

Annotations
@Override
@ParametricNullness
standardContainsback to summary
protected boolean standardContains(Object object)

Overrides com.google.common.collect.ForwardingCollection.standardContains.

A sensible definition of contains in terms of the first() method of tailSet. If you override tailSet, you may wish to override contains to forward to this implementation.

Annotations
@Override
Since
7.0
standardRemoveback to summary
protected boolean standardRemove(Object object)

Overrides com.google.common.collect.ForwardingCollection.standardRemove.

A sensible definition of remove in terms of the iterator() method of tailSet. If you override tailSet, you may wish to override remove to forward to this implementation.

Annotations
@Override
Since
7.0
standardSubSetback to summary
protected SortedSet<E> standardSubSet(E fromElement, E toElement)

A sensible default implementation of subSet(Object, Object) in terms of headSet(Object) and tailSet(Object). In some situations, you may wish to override subSet(Object, Object) to forward to this implementation.

Since
7.0
subSetback to summary
public SortedSet<E> subSet(E fromElement, E toElement)

Implements java.util.SortedSet.subSet.

Doc from java.util.SortedSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the returned set is empty.) The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
fromElement:E

low endpoint (inclusive) of the returned set

toElement:E

high endpoint (exclusive) of the returned set

Returns:SortedSet<E>

a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive

Annotations
@Override
tailSetback to summary
public SortedSet<E> tailSet(E fromElement)

Implements java.util.SortedSet.tailSet.

Doc from java.util.SortedSet.tailSet.

Returns a view of the portion of this set whose elements are greater than or equal to fromElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.

Parameters
fromElement:E

low endpoint (inclusive) of the returned set

Returns:SortedSet<E>

a view of the portion of this set whose elements are greater than or equal to fromElement

Annotations
@Override