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

public abstract Class ForwardingNavigableSet<E extends @Nullable Object>

extends ForwardingSortedSet<E extends @Nullable Object>
implements NavigableSet<E extends @Nullable Object>
Class Inheritance
All Implemented Interfaces
java.util.NavigableSet, 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.DescendingSet
Annotations
@GwtIncompatible
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.GwtIncompatible, java.util.Iterator, .NavigableSet, .SortedSet, javax.annotation.CheckForNull, org.checkerframework.checker.nullness.qual.Nullable

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

Warning

The methods of ForwardingNavigableSet 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 ForwardingNavigableSet.

Each of the standard methods 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.

Author
Louis Wasserman
Since
12.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
ForwardingNavigableSet.StandardDescendingSet

A sensible implementation of NavigableSet#descendingSet in terms of the other methods of NavigableSet, notably including NavigableSet#descendingIterator.

Constructor Summary

AccessConstructor and Description
protected
ForwardingNavigableSet()

Constructor for use by subclasses.

Method Summary

Modifier and TypeMethod and Description
public E
ceiling(E
the value to match
e
)

Implements java.util.NavigableSet.ceiling.

Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
protected abstract NavigableSet<E>
delegate()

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

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

Implements java.util.NavigableSet.descendingIterator.

Returns an iterator over the elements in this set, in descending order.
public NavigableSet<E>
descendingSet()

Implements java.util.NavigableSet.descendingSet.

Returns a reverse order view of the elements contained in this set.
public E
floor(E
the value to match
e
)

Implements java.util.NavigableSet.floor.

Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.
public NavigableSet<E>
headSet(E
high endpoint of the returned set
toElement
,
boolean
true if the high endpoint is to be included in the returned view
inclusive
)

Implements java.util.NavigableSet.headSet.

Returns a view of the portion of this set whose elements are less than (or equal to, if inclusive is true) toElement.
public E
higher(E
the value to match
e
)

Implements java.util.NavigableSet.higher.

Returns the least element in this set strictly greater than the given element, or null if there is no such element.
public E
lower(E
the value to match
e
)

Implements java.util.NavigableSet.lower.

Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
public E
pollFirst()

Implements java.util.NavigableSet.pollFirst.

Retrieves and removes the first (lowest) element, or returns null if this set is empty.
public E
pollLast()

Implements java.util.NavigableSet.pollLast.

Retrieves and removes the last (highest) element, or returns null if this set is empty.
protected E
standardCeiling(E e)

A sensible definition of ceiling in terms of the iterator method of tailSet(Object, boolean).

protected E
protected E
standardFloor(E e)

A sensible definition of floor in terms of the descendingIterator method of headSet(Object, boolean).

protected SortedSet<E>
standardHeadSet(E toElement)

A sensible definition of headSet(Object) in terms of the headSet(Object, boolean) method.

protected E
standardHigher(E e)

A sensible definition of higher in terms of the iterator method of tailSet(Object, boolean).

protected E
protected E
standardLower(E e)

A sensible definition of lower in terms of the descendingIterator method of headSet(Object, boolean).

protected E
standardPollFirst()

A sensible definition of pollFirst in terms of the iterator method.

protected E
standardPollLast()

A sensible definition of pollLast in terms of the descendingIterator method.

protected NavigableSet<E>
standardSubSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)

A sensible definition of subSet(Object, boolean, Object, boolean) in terms of the headSet and tailSet methods.

protected SortedSet<E>
standardSubSet(E fromElement, E toElement)

Overrides com.google.common.collect.ForwardingSortedSet.standardSubSet.

A sensible definition of subSet(Object, Object) in terms of the subSet(Object, boolean, Object, boolean) method.
protected SortedSet<E>
standardTailSet(E fromElement)

A sensible definition of tailSet(Object) in terms of the tailSet(Object, boolean) method.

public NavigableSet<E>
subSet(E
low endpoint of the returned set
fromElement
,
boolean
true if the low endpoint is to be included in the returned view
fromInclusive
,
E
high endpoint of the returned set
toElement
,
boolean
true if the high endpoint is to be included in the returned view
toInclusive
)

Implements java.util.NavigableSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement to toElement.
public NavigableSet<E>
tailSet(E
low endpoint of the returned set
fromElement
,
boolean
true if the low endpoint is to be included in the returned view
inclusive
)

Implements java.util.NavigableSet.tailSet.

Returns a view of the portion of this set whose elements are greater than (or equal to, if inclusive is true) fromElement.
Inherited from com.google.common.collect.ForwardingSortedSet:
comparatorfirstheadSetlaststandardContainsstandardRemovesubSettailSet

Constructor Detail

ForwardingNavigableSetback to summary
protected ForwardingNavigableSet()

Constructor for use by subclasses.

Method Detail

ceilingback to summary
public E ceiling(E e)

Implements java.util.NavigableSet.ceiling.

Doc from java.util.NavigableSet.ceiling.

Returns the least element in this set greater than or equal to the given element, or null if there is no such element.

Parameters
e:E

the value to match

Returns:E

the least element greater than or equal to e, or null if there is no such element

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

Implements abstract com.google.common.collect.ForwardingSortedSet.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
descendingIteratorback to summary
public Iterator<E> descendingIterator()

Implements java.util.NavigableSet.descendingIterator.

Doc from java.util.NavigableSet.descendingIterator.

Returns an iterator over the elements in this set, in descending order. Equivalent in effect to descendingSet().iterator().

Returns:Iterator<E>

an iterator over the elements in this set, in descending order

Annotations
@Override
descendingSetback to summary
public NavigableSet<E> descendingSet()

Implements java.util.NavigableSet.descendingSet.

Doc from java.util.NavigableSet.descendingSet.

Returns a reverse order view of the elements contained in this set. The descending set is backed by this set, so changes to the set are reflected in the descending set, and vice-versa. If either set is modified while an iteration over either set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined.

The returned set has an ordering equivalent to Collections.reverseOrder(comparator()). The expression s.descendingSet().descendingSet() returns a view of s essentially equivalent to s.

Returns:NavigableSet<E>

a reverse order view of this set

Annotations
@Override
floorback to summary
public E floor(E e)

Implements java.util.NavigableSet.floor.

Doc from java.util.NavigableSet.floor.

Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.

Parameters
e:E

the value to match

Returns:E

the greatest element less than or equal to e, or null if there is no such element

Annotations
@Override
@CheckForNull
headSetback to summary
public NavigableSet<E> headSet(E toElement, boolean inclusive)

Implements java.util.NavigableSet.headSet.

Doc from java.util.NavigableSet.headSet.

Returns a view of the portion of this set whose elements are less than (or equal to, if inclusive is true) 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 of the returned set

inclusive:boolean

true if the high endpoint is to be included in the returned view

Returns:NavigableSet<E>

a view of the portion of this set whose elements are less than (or equal to, if inclusive is true) toElement

Annotations
@Override
higherback to summary
public E higher(E e)

Implements java.util.NavigableSet.higher.

Doc from java.util.NavigableSet.higher.

Returns the least element in this set strictly greater than the given element, or null if there is no such element.

Parameters
e:E

the value to match

Returns:E

the least element greater than e, or null if there is no such element

Annotations
@Override
@CheckForNull
lowerback to summary
public E lower(E e)

Implements java.util.NavigableSet.lower.

Doc from java.util.NavigableSet.lower.

Returns the greatest element in this set strictly less than the given element, or null if there is no such element.

Parameters
e:E

the value to match

Returns:E

the greatest element less than e, or null if there is no such element

Annotations
@Override
@CheckForNull
pollFirstback to summary
public E pollFirst()

Implements java.util.NavigableSet.pollFirst.

Doc from java.util.NavigableSet.pollFirst.

Retrieves and removes the first (lowest) element, or returns null if this set is empty.

Returns:E

the first element, or null if this set is empty

Annotations
@Override
@CheckForNull
pollLastback to summary
public E pollLast()

Implements java.util.NavigableSet.pollLast.

Doc from java.util.NavigableSet.pollLast.

Retrieves and removes the last (highest) element, or returns null if this set is empty.

Returns:E

the last element, or null if this set is empty

Annotations
@Override
@CheckForNull
standardCeilingback to summary
protected E standardCeiling(E e)

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

Annotations
@CheckForNull
standardFirstback to summary
protected E standardFirst()
Annotations
@ParametricNullness
standardFloorback to summary
protected E standardFloor(E e)

A sensible definition of floor in terms of the descendingIterator method of headSet(Object, boolean). If you override headSet(Object, boolean), you may wish to override floor to forward to this implementation.

Annotations
@CheckForNull
standardHeadSetback to summary
protected SortedSet<E> standardHeadSet(E toElement)

A sensible definition of headSet(Object) in terms of the headSet(Object, boolean) method. If you override headSet(Object, boolean), you may wish to override headSet(Object) to forward to this implementation.

standardHigherback to summary
protected E standardHigher(E e)

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

Annotations
@CheckForNull
standardLastback to summary
protected E standardLast()
Annotations
@ParametricNullness
standardLowerback to summary
protected E standardLower(E e)

A sensible definition of lower in terms of the descendingIterator method of headSet(Object, boolean). If you override headSet(Object, boolean), you may wish to override lower to forward to this implementation.

Annotations
@CheckForNull
standardPollFirstback to summary
protected E standardPollFirst()

A sensible definition of pollFirst in terms of the iterator method. If you override iterator you may wish to override pollFirst to forward to this implementation.

Annotations
@CheckForNull
standardPollLastback to summary
protected E standardPollLast()

A sensible definition of pollLast in terms of the descendingIterator method. If you override descendingIterator you may wish to override pollLast to forward to this implementation.

Annotations
@CheckForNull
standardSubSetback to summary
protected NavigableSet<E> standardSubSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)

A sensible definition of subSet(Object, boolean, Object, boolean) in terms of the headSet and tailSet methods. In many cases, you may wish to override subSet(Object, boolean, Object, boolean) to forward to this implementation.

standardSubSetback to summary
protected SortedSet<E> standardSubSet(E fromElement, E toElement)

Overrides com.google.common.collect.ForwardingSortedSet.standardSubSet.

A sensible definition of subSet(Object, Object) in terms of the subSet(Object, boolean, Object, boolean) method. If you override subSet(Object, boolean, Object, boolean), you may wish to override subSet(Object, Object) to forward to this implementation.

Annotations
@Override
standardTailSetback to summary
protected SortedSet<E> standardTailSet(E fromElement)

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

subSetback to summary
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)

Implements java.util.NavigableSet.subSet.

Doc from java.util.NavigableSet.subSet.

Returns a view of the portion of this set whose elements range from fromElement to toElement. If fromElement and toElement are equal, the returned set is empty unless fromInclusive and toInclusive are both true. 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 of the returned set

fromInclusive:boolean

true if the low endpoint is to be included in the returned view

toElement:E

high endpoint of the returned set

toInclusive:boolean

true if the high endpoint is to be included in the returned view

Returns:NavigableSet<E>

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

Annotations
@Override
tailSetback to summary
public NavigableSet<E> tailSet(E fromElement, boolean inclusive)

Implements java.util.NavigableSet.tailSet.

Doc from java.util.NavigableSet.tailSet.

Returns a view of the portion of this set whose elements are greater than (or equal to, if inclusive is true) 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 of the returned set

inclusive:boolean

true if the low endpoint is to be included in the returned view

Returns:NavigableSet<E>

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

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

protected Class ForwardingNavigableSet.StandardDescendingSet

extends Sets.DescendingSet<E extends @Nullable Object>
Class Inheritance

A sensible implementation of NavigableSet#descendingSet in terms of the other methods of NavigableSet, notably including NavigableSet#descendingIterator.

In many cases, you may wish to override ForwardingNavigableSet#descendingSet to forward to this implementation or a subclass thereof.

Since
12.0

Constructor Summary

AccessConstructor and Description
public
StandardDescendingSet()

Constructor for use by subclasses.

Method Summary

Inherited from com.google.common.collect.Sets.DescendingSet:
ceilingcomparatordelegatedescendingIteratordescendingSetfirstfloorheadSetheadSethigheriteratorlastlowerpollFirstpollLastsubSetsubSettailSettailSettoArraytoArraytoString

Constructor Detail

StandardDescendingSetback to summary
public StandardDescendingSet()

Constructor for use by subclasses.