Class ForwardingNavigableSet.StandardDescendingSet
-
- com.google.common.collect.ForwardingObject
-
- com.google.common.collect.ForwardingCollection<E>
-
- com.google.common.collect.ForwardingSet<E>
-
- com.google.common.collect.ForwardingSortedSet<E>
-
- com.google.common.collect.ForwardingNavigableSet<E>
-
- com.google.common.collect.ForwardingNavigableSet.StandardDescendingSet
-
- All Implemented Interfaces:
<E>
,<E>
,<E>
,<E>
,<E>
- Enclosing class:
- ForwardingNavigableSet<E>
@Beta protected class ForwardingNavigableSet.StandardDescendingSet extends ForwardingNavigableSet<E>
A sensible implementation of in terms of the other methods of , notably including .In many cases, you may wish to override
ForwardingNavigableSet.descendingSet()
to forward to this implementation or a subclass thereof.- Since:
- 12.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.ForwardingNavigableSet
ForwardingNavigableSet.StandardDescendingSet
-
-
Constructor Summary
Constructors Constructor Description StandardDescendingSet()
Constructor for use by subclasses.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description E
ceiling(E e)
Returns the least element in this set greater than or equal to the given element, ornull
if there is no such element.<? super E>
comparator()
Returns the comparator used to order the elements in this set, ornull
if this set uses the of its elements.protected <E>
delegate()
Returns the backing delegate instance that methods are forwarded to.<E>
descendingIterator()
Returns an iterator over the elements in this set, in descending order.<E>
descendingSet()
Returns a reverse order view of the elements contained in this set.E
first()
Returns the first (lowest) element currently in this set.E
floor(E e)
Returns the greatest element in this set less than or equal to the given element, ornull
if there is no such element.<E>
headSet(E toElement)
Returns a view of the portion of this set whose elements are strictly less thantoElement
.<E>
headSet(E toElement, boolean inclusive)
Returns a view of the portion of this set whose elements are less than (or equal to, ifinclusive
is true)toElement
.E
higher(E e)
Returns the least element in this set strictly greater than the given element, ornull
if there is no such element.<E>
iterator()
Returns an iterator over the elements in this collection.E
last()
Returns the last (highest) element currently in this set.E
lower(E e)
Returns the greatest element in this set strictly less than the given element, ornull
if there is no such element.E
pollFirst()
Retrieves and removes the first (lowest) element, or returnsnull
if this set is empty.E
pollLast()
Retrieves and removes the last (highest) element, or returnsnull
if this set is empty.<E>
subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
Returns a view of the portion of this set whose elements range fromfromElement
totoElement
.<E>
subSet(E fromElement, E toElement)
Returns a view of the portion of this set whose elements range fromfromElement
, inclusive, totoElement
, exclusive.<E>
tailSet(E fromElement)
Returns a view of the portion of this set whose elements are greater than or equal tofromElement
.<E>
tailSet(E fromElement, boolean inclusive)
Returns a view of the portion of this set whose elements are greater than (or equal to, ifinclusive
is true)fromElement
.[]
toArray()
Returns an array containing all of the elements in this collection.<T> T[]
toArray(T[] array)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.toString()
Returns the string representation generated by the delegate'stoString
method.-
Methods inherited from class com.google.common.collect.ForwardingNavigableSet
standardCeiling, standardFirst, standardFloor, standardHeadSet, standardHigher, standardLast, standardLower, standardPollFirst, standardPollLast, standardSubSet, standardSubSet, standardTailSet
-
Methods inherited from class com.google.common.collect.ForwardingSortedSet
standardContains, standardRemove
-
Methods inherited from class com.google.common.collect.ForwardingSet
equals, hashCode, standardEquals, standardHashCode, standardRemoveAll
-
Methods inherited from class com.google.common.collect.ForwardingCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContainsAll, standardIsEmpty, standardRetainAll, standardToArray, standardToArray, standardToString
-
-
-
-
Constructor Detail
-
StandardDescendingSet
public StandardDescendingSet()
Constructor for use by subclasses.
-
-
Method Detail
-
delegate
protected <E> delegate()
Description copied from class:ForwardingObject
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 asForwardingSet.delegate()
. Concrete subclasses override this method to supply the instance being decorated.- Specified by:
delegate
in classForwardingNavigableSet<E>
-
lower
public E lower(E e)
Description copied from interface:Returns the greatest element in this set strictly less than the given element, ornull
if there is no such element.- Specified by:
in interface
<E>
- Overrides:
lower
in classForwardingNavigableSet<E>
- Parameters:
e
- the value to match- Returns:
- the greatest element less than
e
, ornull
if there is no such element
-
floor
public E floor(E e)
Description copied from interface:Returns the greatest element in this set less than or equal to the given element, ornull
if there is no such element.- Specified by:
in interface
<E>
- Overrides:
floor
in classForwardingNavigableSet<E>
- Parameters:
e
- the value to match- Returns:
- the greatest element less than or equal to
e
, ornull
if there is no such element
-
ceiling
public E ceiling(E e)
Description copied from interface:Returns the least element in this set greater than or equal to the given element, ornull
if there is no such element.- Specified by:
in interface
<E>
- Overrides:
ceiling
in classForwardingNavigableSet<E>
- Parameters:
e
- the value to match- Returns:
- the least element greater than or equal to
e
, ornull
if there is no such element
-
higher
public E higher(E e)
Description copied from interface:Returns the least element in this set strictly greater than the given element, ornull
if there is no such element.- Specified by:
in interface
<E>
- Overrides:
higher
in classForwardingNavigableSet<E>
- Parameters:
e
- the value to match- Returns:
- the least element greater than
e
, ornull
if there is no such element
-
pollFirst
public E pollFirst()
Description copied from interface:Retrieves and removes the first (lowest) element, or returnsnull
if this set is empty.- Specified by:
in interface
<E>
- Overrides:
pollFirst
in classForwardingNavigableSet<E>
- Returns:
- the first element, or
null
if this set is empty
-
pollLast
public E pollLast()
Description copied from interface:Retrieves and removes the last (highest) element, or returnsnull
if this set is empty.- Specified by:
in interface
<E>
- Overrides:
pollLast
in classForwardingNavigableSet<E>
- Returns:
- the last element, or
null
if this set is empty
-
descendingSet
public <E> descendingSet()
Description copied from interface: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 ownremove
operation), the results of the iteration are undefined.The returned set has an ordering equivalent to
(comparator())
. The expressions.descendingSet().descendingSet()
returns a view ofs
essentially equivalent tos
.- Specified by:
in interface
<E>
- Overrides:
descendingSet
in classForwardingNavigableSet<E>
- Returns:
- a reverse order view of this set
-
descendingIterator
public <E> descendingIterator()
Description copied from interface:Returns an iterator over the elements in this set, in descending order. Equivalent in effect todescendingSet().iterator()
.- Specified by:
in interface
<E>
- Overrides:
descendingIterator
in classForwardingNavigableSet<E>
- Returns:
- an iterator over the elements in this set, in descending order
-
subSet
public <E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
Description copied from interface:Returns a view of the portion of this set whose elements range fromfromElement
totoElement
. IffromElement
andtoElement
are equal, the returned set is empty unlessfromInclusive
andtoInclusive
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.- Specified by:
in interface
<E>
- Overrides:
subSet
in classForwardingNavigableSet<E>
- Parameters:
fromElement
- low endpoint of the returned setfromInclusive
-true
if the low endpoint is to be included in the returned viewtoElement
- high endpoint of the returned settoInclusive
-true
if the high endpoint is to be included in the returned view- Returns:
- a view of the portion of this set whose elements range from
fromElement
, inclusive, totoElement
, exclusive
-
subSet
public <E> subSet(E fromElement, E toElement)
Description copied from interface:Returns a view of the portion of this set whose elements range fromfromElement
, inclusive, totoElement
, exclusive. (IffromElement
andtoElement
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.- Specified by:
in interface
<E>
- Specified by:
in interface
<E>
- Overrides:
subSet
in classForwardingSortedSet<E>
- Parameters:
fromElement
- low endpoint (inclusive) of the returned settoElement
- high endpoint (exclusive) of the returned set- Returns:
- a view of the portion of this set whose elements range from
fromElement
, inclusive, totoElement
, exclusive
-
headSet
public <E> headSet(E toElement, boolean inclusive)
Description copied from interface:Returns a view of the portion of this set whose elements are less than (or equal to, ifinclusive
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.- Specified by:
in interface
<E>
- Overrides:
headSet
in classForwardingNavigableSet<E>
- Parameters:
toElement
- high endpoint of the returned setinclusive
-true
if the high endpoint is to be included in the returned view- Returns:
- a view of the portion of this set whose elements are less than
(or equal to, if
inclusive
is true)toElement
-
headSet
public <E> headSet(E toElement)
Description copied from interface:Returns a view of the portion of this set whose elements are strictly less thantoElement
. 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.- Specified by:
in interface
<E>
- Specified by:
in interface
<E>
- Overrides:
headSet
in classForwardingSortedSet<E>
- Parameters:
toElement
- high endpoint (exclusive) of the returned set- Returns:
- a view of the portion of this set whose elements are strictly
less than
toElement
-
tailSet
public <E> tailSet(E fromElement, boolean inclusive)
Description copied from interface:Returns a view of the portion of this set whose elements are greater than (or equal to, ifinclusive
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.- Specified by:
in interface
<E>
- Overrides:
tailSet
in classForwardingNavigableSet<E>
- Parameters:
fromElement
- low endpoint of the returned setinclusive
-true
if the low endpoint is to be included in the returned view- Returns:
- a view of the portion of this set whose elements are greater
than or equal to
fromElement
-
tailSet
public <E> tailSet(E fromElement)
Description copied from interface:Returns a view of the portion of this set whose elements are greater than or equal tofromElement
. 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.- Specified by:
in interface
<E>
- Specified by:
in interface
<E>
- Overrides:
tailSet
in classForwardingSortedSet<E>
- Parameters:
fromElement
- low endpoint (inclusive) of the returned set- Returns:
- a view of the portion of this set whose elements are greater
than or equal to
fromElement
-
comparator
public <? super E> comparator()
Description copied from interface:Returns the comparator used to order the elements in this set, ornull
if this set uses the of its elements.- Specified by:
in interface
<E>
- Overrides:
comparator
in classForwardingSortedSet<E>
- Returns:
- the comparator used to order the elements in this set,
or
null
if this set uses the natural ordering of its elements
-
first
public E first()
Description copied from interface:Returns the first (lowest) element currently in this set.- Specified by:
in interface
<E>
- Overrides:
first
in classForwardingSortedSet<E>
- Returns:
- the first (lowest) element currently in this set
-
last
public E last()
Description copied from interface:Returns the last (highest) element currently in this set.- Specified by:
in interface
<E>
- Overrides:
last
in classForwardingSortedSet<E>
- Returns:
- the last (highest) element currently in this set
-
iterator
public <E> iterator()
Description copied from interface:Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).- Specified by:
in interface
<E>
- Specified by:
in interface
<E>
- Specified by:
in interface
<E>
- Specified by:
in interface
<E>
- Overrides:
iterator
in classForwardingCollection<E>
- Returns:
- an
Iterator
over the elements in this collection
-
toArray
public [] toArray()
Description copied from interface:Returns an array containing all of the elements in this collection. If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array's isObject
.The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.
- Specified by:
in interface
<E>
- Specified by:
in interface
<E>
- Overrides:
toArray
in classForwardingCollection<E>
- Returns:
- an array, whose is
Object
, containing all of the elements in this collection
-
toArray
public <T> T[] toArray(T[] array)
Description copied from interface:Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to
null
. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain anynull
elements.)If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
- Specified by:
in interface
<E>
- Specified by:
in interface
<E>
- Overrides:
toArray
in classForwardingCollection<E>
- Type Parameters:
T
- the component type of the array to contain the collection- Parameters:
array
- the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.- Returns:
- an array containing all of the elements in this collection
-
toString
public toString()
Description copied from class:ForwardingObject
Returns the string representation generated by the delegate'stoString
method.- Overrides:
toString
in classForwardingObject
- Returns:
- a string representation of the object.
-
-