Class ForwardingNavigableMap.StandardNavigableKeySet

    • Constructor Summary

      Constructors 
      Constructor Description
      StandardNavigableKeySet()
      Constructor for use by subclasses.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      K ceiling(K e)
      Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
      void clear()
      Removes all of the elements from this collection (optional operation).
      Comparator<? super K> comparator()
      Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.
      boolean contains(Object o)
      Returns true if this collection contains the specified element.
      Iterator<K> descendingIterator()
      Returns an iterator over the elements in this set, in descending order.
      NavigableSet<K> descendingSet()
      Returns a reverse order view of the elements contained in this set.
      K first()
      Returns the first (lowest) element currently in this set.
      K floor(K e)
      Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.
      void forEach(Consumer<? super K> action)
      Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
      SortedSet<K> headSet(K toElement)
      Returns a view of the portion of this set whose elements are strictly less than toElement.
      NavigableSet<K> headSet(K 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.
      K higher(K e)
      Returns the least element in this set strictly greater than the given element, or null if there is no such element.
      boolean isEmpty()
      Returns true if this collection contains no elements.
      Iterator<K> iterator()
      Returns an iterator over the elements contained in this collection.
      K last()
      Returns the last (highest) element currently in this set.
      K lower(K e)
      Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
      K pollFirst()
      Retrieves and removes the first (lowest) element, or returns null if this set is empty.
      K pollLast()
      Retrieves and removes the last (highest) element, or returns null if this set is empty.
      boolean remove(Object o)
      Removes a single instance of the specified element from this collection, if it is present (optional operation).
      boolean removeAll(Collection<?> c)
      Removes from this set all of its elements that are contained in the specified collection (optional operation).
      boolean retainAll(Collection<?> c)
      Retains only the elements in this collection that are contained in the specified collection (optional operation).
      int size()
      Returns the number of elements in this collection.
      NavigableSet<K> subSet(K fromElement, boolean fromInclusive, K toElement, boolean toInclusive)
      Returns a view of the portion of this set whose elements range from fromElement to toElement.
      SortedSet<K> subSet(K fromElement, K toElement)
      Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
      SortedSet<K> tailSet(K fromElement)
      Returns a view of the portion of this set whose elements are greater than or equal to fromElement.
      NavigableSet<K> tailSet(K 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.
    • Method Detail

      • lower

        public K lower(K e)
        Description copied from interface: java.util.NavigableSet
        Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
        Specified by:
        lower in interface NavigableSet<K>
        Parameters:
        e - the value to match
        Returns:
        the greatest element less than e, or null if there is no such element
      • floor

        public K floor(K e)
        Description copied from interface: java.util.NavigableSet
        Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.
        Specified by:
        floor in interface NavigableSet<K>
        Parameters:
        e - the value to match
        Returns:
        the greatest element less than or equal to e, or null if there is no such element
      • ceiling

        public K ceiling(K e)
        Description copied from interface: java.util.NavigableSet
        Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
        Specified by:
        ceiling in interface NavigableSet<K>
        Parameters:
        e - the value to match
        Returns:
        the least element greater than or equal to e, or null if there is no such element
      • higher

        public K higher(K e)
        Description copied from interface: java.util.NavigableSet
        Returns the least element in this set strictly greater than the given element, or null if there is no such element.
        Specified by:
        higher in interface NavigableSet<K>
        Parameters:
        e - the value to match
        Returns:
        the least element greater than e, or null if there is no such element
      • pollFirst

        public K pollFirst()
        Description copied from interface: java.util.NavigableSet
        Retrieves and removes the first (lowest) element, or returns null if this set is empty.
        Specified by:
        pollFirst in interface NavigableSet<K>
        Returns:
        the first element, or null if this set is empty
      • pollLast

        public K pollLast()
        Description copied from interface: java.util.NavigableSet
        Retrieves and removes the last (highest) element, or returns null if this set is empty.
        Specified by:
        pollLast in interface NavigableSet<K>
        Returns:
        the last element, or null if this set is empty
      • descendingSet

        public NavigableSet<K> descendingSet()
        Description copied from interface: java.util.NavigableSet
        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.

        Specified by:
        descendingSet in interface NavigableSet<K>
        Returns:
        a reverse order view of this set
      • descendingIterator

        public Iterator<K> descendingIterator()
        Description copied from interface: java.util.NavigableSet
        Returns an iterator over the elements in this set, in descending order. Equivalent in effect to descendingSet().iterator().
        Specified by:
        descendingIterator in interface NavigableSet<K>
        Returns:
        an iterator over the elements in this set, in descending order
      • subSet

        public NavigableSet<K> subSet(K fromElement,
                                      boolean fromInclusive,
                                      K toElement,
                                      boolean toInclusive)
        Description copied from interface: java.util.NavigableSet
        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.

        Specified by:
        subSet in interface NavigableSet<K>
        Parameters:
        fromElement - low endpoint of the returned set
        fromInclusive - true if the low endpoint is to be included in the returned view
        toElement - high endpoint of the returned set
        toInclusive - 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, to toElement, exclusive
      • subSet

        public SortedSet<K> subSet(K fromElement,
                                   K toElement)
        Description copied from interface: java.util.SortedSet
        Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement 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:
        subSet in interface NavigableSet<K>
        Specified by:
        subSet in interface SortedSet<K>
        Parameters:
        fromElement - low endpoint (inclusive) of the returned set
        toElement - high endpoint (exclusive) of the returned set
        Returns:
        a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive
      • headSet

        public NavigableSet<K> headSet(K toElement,
                                       boolean inclusive)
        Description copied from interface: java.util.NavigableSet
        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.

        Specified by:
        headSet in interface NavigableSet<K>
        Parameters:
        toElement - high endpoint of the returned set
        inclusive - 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 SortedSet<K> headSet(K toElement)
        Description copied from interface: java.util.SortedSet
        Returns a view of the portion of this set whose elements are strictly less than 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:
        headSet in interface NavigableSet<K>
        Specified by:
        headSet in interface SortedSet<K>
        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 NavigableSet<K> tailSet(K fromElement,
                                       boolean inclusive)
        Description copied from interface: java.util.NavigableSet
        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.

        Specified by:
        tailSet in interface NavigableSet<K>
        Parameters:
        fromElement - low endpoint of the returned set
        inclusive - 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 SortedSet<K> tailSet(K fromElement)
        Description copied from interface: java.util.SortedSet
        Returns a view of the portion of this set whose elements are greater than or equal to 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:
        tailSet in interface NavigableSet<K>
        Specified by:
        tailSet in interface SortedSet<K>
        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 Comparator<? super K> comparator()
        Description copied from interface: java.util.SortedSet
        Returns the comparator used to order the elements in this set, or null if this set uses the natural ordering of its elements.
        Specified by:
        comparator in interface SortedSet<K>
        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 K first()
        Description copied from interface: java.util.SortedSet
        Returns the first (lowest) element currently in this set.
        Specified by:
        first in interface SortedSet<K>
        Returns:
        the first (lowest) element currently in this set
      • last

        public K last()
        Description copied from interface: java.util.SortedSet
        Returns the last (highest) element currently in this set.
        Specified by:
        last in interface SortedSet<K>
        Returns:
        the last (highest) element currently in this set
      • forEach

        public void forEach(Consumer<? super K> action)
        Description copied from interface: java.lang.Iterable
        Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.

        The behavior of this method is unspecified if the action performs side-effects that modify the underlying source of elements, unless an overriding class has specified a concurrent modification policy.

        Parameters:
        action - The action to be performed for each element
      • size

        public int size()
        Description copied from interface: java.util.Collection
        Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
        Specified by:
        size in interface Collection<K>
        Specified by:
        size in interface Set<K>
        Specified by:
        size in class AbstractCollection<K>
        Returns:
        the number of elements in this collection
      • contains

        public boolean contains(Object o)
        Description copied from class: java.util.AbstractCollection
        Returns true if this collection contains the specified element. More formally, returns true if and only if this collection contains at least one element e such that Objects.equals(o, e).
        Specified by:
        contains in interface Collection<K>
        Specified by:
        contains in interface Set<K>
        Overrides:
        contains in class AbstractCollection<K>
        Parameters:
        o - element whose presence in this collection is to be tested
        Returns:
        true if this collection contains the specified element
      • remove

        public boolean remove(Object o)
        Description copied from class: java.util.AbstractCollection
        Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).
        Specified by:
        remove in interface Collection<K>
        Specified by:
        remove in interface Set<K>
        Overrides:
        remove in class AbstractCollection<K>
        Parameters:
        o - element to be removed from this collection, if present
        Returns:
        true if an element was removed as a result of this call
      • removeAll

        public boolean removeAll(Collection<?> c)
        Description copied from class: java.util.AbstractSet
        Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.

        This implementation determines which is the smaller of this set and the specified collection, by invoking the size method on each. If this set has fewer elements, then the implementation iterates over this set, checking each element returned by the iterator in turn to see if it is contained in the specified collection. If it is so contained, it is removed from this set with the iterator's remove method. If the specified collection has fewer elements, then the implementation iterates over the specified collection, removing from this set each element returned by the iterator, using this set's remove method.

        Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method.

        Specified by:
        removeAll in interface Collection<E>
        Specified by:
        removeAll in interface Set<E>
        Overrides:
        removeAll in class AbstractSet<E>
        Parameters:
        c - collection containing elements to be removed from this set
        Returns:
        true if this set changed as a result of the call
        See Also:
        AbstractCollection.remove(Object), AbstractCollection.contains(Object)