java.util · java.base · since Java 1.6

NavigableSet

declaration
public interface NavigableSet<E> extends SortedSet<E>

A SortedSet with nearest-match navigation and descending views. TreeSet is the standard implementation.

Key methods

E ceiling(E e) / floor(E e)Least element >= e / greatest element <= e (null if none).
E higher(E e) / lower(E e)Strictly greater / strictly lesser neighbor.
E pollFirst() / pollLast()Retrieve and remove the lowest / highest element.
NavigableSet<E> descendingSet()Reverse-order view over the same elements.
NavigableSet<E> subSet(E from, boolean fromInc, E to, boolean toInc)Range view with inclusive/exclusive endpoints.