The return values of navigation methods may be ambiguous in implementations that permit null elements. However, even in this case the result can be disambiguated by checking contains(null). To avoid such issues, implementations of this interface are encouraged to not permit insertion of null elements. (Note that sorted sets of Comparable elements intrinsically do not permit null.)
Methods subSet(E, E), headSet(E), and tailSet(E) are specified to return SortedSet to allow existing implementations of SortedSet to be compatibly retrofitted to implement NavigableSet, but extensions and implementations of this interface are encouraged to override these methods to return NavigableSet.
This interface is a member of the Java Collections Framework.
| Method Summary | ||
| ceiling(E e) Returns the least element in this set greater than or equal to
the given element, or null if there is no such element. |
||
| descendingIterator() Returns an iterator over the elements in this set, in descending order. |
||
| descendingSet() Returns a reverse order view of the elements contained in this set. |
||
| floor(E e) Returns the greatest element in this set less than or equal to
the given element, or null if there is no such element. |
||
| headSet(E toElement) Returns a view of the portion of this set whose elements are
strictly less than toElement. |
||
| headSet(E toElement, boolean inclusive) Returns a view of the portion of this set whose elements are less than
(or equal to, if inclusive is true) toElement. |
||
| higher(E e) Returns the least element in this set strictly greater than the
given element, or null if there is no such element. |
||
| iterator() Returns an iterator over the elements in this set, in ascending order. |
||
| lower(E e) Returns the greatest element in this set strictly less than the
given element, or null if there is no such element. |
||
| pollFirst() Retrieves and removes the first (lowest) element,
or returns null if this set is empty. |
||
| pollLast() Retrieves and removes the last (highest) element,
or returns null if this set is empty. |
||
| subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) Returns a view of the portion of this set whose elements range from
fromElement to toElement. |
||
| subSet(E fromElement, E toElement) Returns a view of the portion of this set whose elements range
from fromElement, inclusive, to toElement,
exclusive. |
||
| tailSet(E fromElement) Returns a view of the portion of this set whose elements are
greater than or equal to fromElement. |
||
| tailSet(E fromElement, boolean inclusive) Returns a view of the portion of this set whose elements are greater
than (or equal to, if inclusive is true) fromElement. |
||
| Methods inherited from interface java.util.SortedSet |
| comparator, first, last |
| Methods inherited from interface java.util.Set |
| add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray |
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.
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
Equivalent to subSet(fromElement, true, toElement, false).
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
Equivalent to headSet(toElement, false).
The returned set will throw an IllegalArgumentException on an attempt to insert an element outside its range.
Equivalent to tailSet(fromElement, true).