public interface NavigableSet<E>
ExtendsCollection<E>, Iterable<E>, Set<E>, SortedSet<E>
Known subtypesTreeSet
NavigableSet is a SortedSet with navigation methods answering the closest matches for specified item.
Type parameter E: the type of element
Methods
public abstract E pollFirst() | Deletes and answers the smallest element, or null if the set is empty. |
public abstract E pollLast() | Deletes and answers the biggest element, or null if the set is empty. |
public abstract E higher(E e) | Answers the smallest element bigger than the specified one, or null if no such element. |
public abstract E ceiling(E e) | Answers the smallest element bigger than or equal to the specified one, or null if no such element. |
public abstract E lower(E e) | Answers the biggest element less than the specified one, or null if no such element. |
public abstract E floor(E e) | Answers the biggest element less than or equal to the specified one, or null if no such element. |
public abstract Iterator<E> descendingIterator() | Answers a descending iterator of this set. |
public abstract NavigableSet<E> descendingSet() | Answers a reverse order view of this set. |
public abstract NavigableSet<E> subSet(E start, boolean startInclusive, E end, boolean endInclusive) | Answers a NavigableSet of the specified portion of this set which contains elements greater (or equal to, depends on startInclusive) the start element but less than (or equal to, depends on endInclusive) the end element. |
public abstract NavigableSet<E> headSet(E end, boolean endInclusive) | Answers a NavigableSet of the specified portion of this set which contains elements less than (or equal to, depends on endInclusive) the end element. |
public abstract NavigableSet<E> tailSet(E start, boolean startInclusive) | Answers a NavigableSet of the specified portion of this set which contains elements greater (or equal to, depends on startInclusive) the start element. |
Inherited methods
From Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
From Collection
Method details
pollFirst
public abstract E pollFirst()Deletes and answers the smallest element, or null if the set is empty.
Returns
the smallest element, or null if the set is empty
pollLast
public abstract E pollLast()Deletes and answers the biggest element, or null if the set is empty.
Returns
the biggest element, or null if the set is empty
higher
public abstract E higher(E e)Answers the smallest element bigger than the specified one, or null if no
such element.
Parameters
eE- the specified element
Returns
the smallest element bigger than the specified one, or null if no
such element
Throws
ClassCastException- if the element cannot be compared with the ones in the set
NullPointerException- if the element is null and the set can not contain null
ceiling
public abstract E ceiling(E e)Answers the smallest element bigger than or equal to the specified one,
or null if no such element.
Parameters
eE- the specified element
Returns
the smallest element bigger than or equal to the specified one,
or null if no such element
Throws
ClassCastException- if the element cannot be compared with the ones in the set
NullPointerException- if the element is null and the set can not contain null
lower
public abstract E lower(E e)Answers the biggest element less than the specified one, or null if no
such element.
Parameters
eE- the specified element
Returns
the biggest element less than the specified one, or null if no
such element
Throws
ClassCastException- if the element cannot be compared with the ones in the set
NullPointerException- if the element is null and the set can not contain null
floor
public abstract E floor(E e)Answers the biggest element less than or equal to the specified one, or
null if no such element.
Parameters
eE- the specified element
Returns
the biggest element less than or equal to the specified one, or
null if no such element
Throws
ClassCastException- if the element cannot be compared with the ones in the set
NullPointerException- if the element is null and the set can not contain null
descendingIterator
public abstract Iterator<E> descendingIterator()Answers a descending iterator of this set.
Returns
the descending iterator
descendingSet
public abstract NavigableSet<E> descendingSet()Answers a reverse order view of this set.
Returns
the reverse order view
subSet
public abstract NavigableSet<E> subSet(E start, boolean startInclusive, E end, boolean endInclusive)Answers a NavigableSet of the specified portion of this set which
contains elements greater (or equal to, depends on startInclusive) the
start element but less than (or equal to, depends on endInclusive) the
end element. The returned NavigableSet is backed by this set so changes
to one are reflected by the other.
Parameters
startE- the start element
startInclusiveboolean- true if the start element is in the returned set
endE- the end element
endInclusiveboolean- true if the end element is in the returned set
Returns
the subset
Throws
ClassCastException- when the start or end object cannot be compared with the elements in this set
NullPointerException- when the start or end object is null and the set cannot contain null
IllegalArgumentException- when the start is bigger than end; or start or end is out of range and the set has a range
headSet
public abstract NavigableSet<E> headSet(E end, boolean endInclusive)Answers a NavigableSet of the specified portion of this set which
contains elements less than (or equal to, depends on endInclusive) the
end element. The returned NavigableSet is backed by this set so changes
to one are reflected by the other.
Parameters
endE- the end element
endInclusiveboolean- true if the end element is in the returned set
Returns
the subset
Throws
ClassCastException- when the end object cannot be compared with the elements in this set
NullPointerException- when the end object is null and the set cannot contain handle null
IllegalArgumentException- when end is out of range and the set has a range
tailSet
public abstract NavigableSet<E> tailSet(E start, boolean startInclusive)Answers a NavigableSet of the specified portion of this set which
contains elements greater (or equal to, depends on startInclusive) the
start element. The returned NavigableSet is backed by this set so changes
to one are reflected by the other.
Parameters
startE- the start element
startInclusiveboolean- true if the start element is in the returned set
Returns
the subset
Throws
ClassCastException- when the start object cannot be compared with the elements in this set
NullPointerException- when the start object is null and the set cannot contain null
IllegalArgumentException- when start is out of range and the set has a range