com.google.common.collect

## Class ForwardingNavigableSet<E>

- java.lang.Object
- - 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>

- All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.NavigableSet<E>, java.util.Set<E>, java.util.SortedSet<E>
  Direct Known Subclasses:
    ForwardingNavigableSet.StandardDescendingSet

      public abstract class ForwardingNavigableSet<E>
      extends ForwardingSortedSet<E>
      implements java.util.NavigableSet<E>

  A navigable set which forwards all its method calls to another navigable set. Subclasses should override one or more methods to modify the behavior of the backing set as desired per the decorator pattern.

  Warning: The methods of `ForwardingNavigableSet` forward indiscriminately to the methods of the delegate. For example, overriding `ForwardingCollection.add(E)` alone will not change the behavior of `ForwardingCollection.addAll(java.util.Collection<? extends E>)`, which can lead to unexpected behavior. In this case, you should override `addAll` as well, either providing your own implementation, or delegating to the provided `standardAddAll` method.

  Each of the `standard` methods uses the set's comparator (or the natural ordering of the elements, if there is no comparator) to test element equality. As a result, if the comparator is not consistent with equals, some of the standard implementations may violate the `Set` contract.

  The `standard` methods and the collection views they return are not guaranteed to be thread-safe, even when all of the methods that they depend on are thread-safe.

  Since:
    12.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `ForwardingNavigableSet.StandardDescendingSet` A sensible implementation of `NavigableSet.descendingSet()` in terms of the other methods of `NavigableSet`, notably including `NavigableSet.descendingIterator()`.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ForwardingNavigableSet()` Constructor for use by subclasses.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `E` | `ceiling(E e)`
    `protected abstract java.util.NavigableSet<E>` | `delegate()` Returns the backing delegate instance that methods are forwarded to.
    `java.util.Iterator<E>` | `descendingIterator()`
    `java.util.NavigableSet<E>` | `descendingSet()`
    `E` | `floor(E e)`
    `java.util.NavigableSet<E>` | `headSet(E toElement, boolean inclusive)`
    `E` | `higher(E e)`
    `E` | `lower(E e)`
    `E` | `pollFirst()`
    `E` | `pollLast()`
    `protected E` | `standardCeiling(E e)` A sensible definition of `ceiling(E)` in terms of the `iterator` method of `tailSet(Object, boolean)`.
    `protected E` | `standardFirst()`
    `protected E` | `standardFloor(E e)` A sensible definition of `floor(E)` in terms of the `descendingIterator` method of `headSet(Object, boolean)`.
    `protected java.util.SortedSet<E>` | `standardHeadSet(E toElement)` A sensible definition of `ForwardingSortedSet.headSet(Object)` in terms of the `headSet(Object, boolean)` method.
    `protected E` | `standardHigher(E e)` A sensible definition of `higher(E)` in terms of the `iterator` method of `tailSet(Object, boolean)`.
    `protected E` | `standardLast()`
    `protected E` | `standardLower(E e)` A sensible definition of `lower(E)` in terms of the `descendingIterator` method of `headSet(Object, boolean)`.
    `protected E` | `standardPollFirst()` A sensible definition of `pollFirst()` in terms of the `iterator` method.
    `protected E` | `standardPollLast()` A sensible definition of `pollLast()` in terms of the `descendingIterator` method.
    `protected java.util.NavigableSet<E>` | `standardSubSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)` A sensible definition of `subSet(Object, boolean, Object, boolean)` in terms of the `headSet` and `tailSet` methods.
    `protected java.util.SortedSet<E>` | `standardSubSet(E fromElement, E toElement)` A sensible definition of `ForwardingSortedSet.subSet(Object, Object)` in terms of the `subSet(Object, boolean, Object, boolean)` method.
    `protected java.util.SortedSet<E>` | `standardTailSet(E fromElement)` A sensible definition of `ForwardingSortedSet.tailSet(Object)` in terms of the `tailSet(Object, boolean)` method.
    `java.util.NavigableSet<E>` | `subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)`
    `java.util.NavigableSet<E>` | `tailSet(E fromElement, boolean inclusive)`

    - ### Methods inherited from class com.google.common.collect.ForwardingSortedSet

      `comparator, first, headSet, last, standardContains, standardRemove, subSet, tailSet`

    - ### 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, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContainsAll, standardIsEmpty, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray`

    - ### Methods inherited from class com.google.common.collect.ForwardingObject

      `toString`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.NavigableSet

      `headSet, iterator, subSet, tailSet`

    - ### 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`

- - ### Constructor Detail

    - #### ForwardingNavigableSet

          protected ForwardingNavigableSet()

      Constructor for use by subclasses.

  - ### Method Detail

    - #### delegate

          protected abstract java.util.NavigableSet<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 as `ForwardingSet.delegate()`. Concrete subclasses override this method to supply the instance being decorated.
      Specified by:
        `delegate` in class `ForwardingSortedSet<E>`

    - #### lower

          public E lower(E e)

      Specified by:
        `lower` in interface `java.util.NavigableSet<E>`

    - #### standardLower

          protected E standardLower(E e)

      A sensible definition of `lower(E)` in terms of the `descendingIterator` method of `headSet(Object, boolean)`. If you override `headSet(Object, boolean)`, you may wish to override `lower(E)` to forward to this implementation.

    - #### floor

          public E floor(E e)

      Specified by:
        `floor` in interface `java.util.NavigableSet<E>`

    - #### standardFloor

          protected E standardFloor(E e)

      A sensible definition of `floor(E)` in terms of the `descendingIterator` method of `headSet(Object, boolean)`. If you override `headSet(Object, boolean)`, you may wish to override `floor(E)` to forward to this implementation.

    - #### ceiling

          public E ceiling(E e)

      Specified by:
        `ceiling` in interface `java.util.NavigableSet<E>`

    - #### standardCeiling

          protected E standardCeiling(E e)

      A sensible definition of `ceiling(E)` in terms of the `iterator` method of `tailSet(Object, boolean)`. If you override `tailSet(Object, boolean)`, you may wish to override `ceiling(E)` to forward to this implementation.

    - #### higher

          public E higher(E e)

      Specified by:
        `higher` in interface `java.util.NavigableSet<E>`

    - #### standardHigher

          protected E standardHigher(E e)

      A sensible definition of `higher(E)` in terms of the `iterator` method of `tailSet(Object, boolean)`. If you override `tailSet(Object, boolean)`, you may wish to override `higher(E)` to forward to this implementation.

    - #### pollFirst

          public E pollFirst()

      Specified by:
        `pollFirst` in interface `java.util.NavigableSet<E>`

    - #### standardPollFirst

          protected E standardPollFirst()

      A sensible definition of `pollFirst()` in terms of the `iterator` method. If you override `ForwardingCollection.iterator()` you may wish to override `pollFirst()` to forward to this implementation.

    - #### pollLast

          public E pollLast()

      Specified by:
        `pollLast` in interface `java.util.NavigableSet<E>`

    - #### standardPollLast

          protected E standardPollLast()

      A sensible definition of `pollLast()` in terms of the `descendingIterator` method. If you override `descendingIterator()` you may wish to override `pollLast()` to forward to this implementation.

    - #### standardFirst

          protected E standardFirst()

    - #### standardLast

          protected E standardLast()

    - #### descendingSet

          public java.util.NavigableSet<E> descendingSet()

      Specified by:
        `descendingSet` in interface `java.util.NavigableSet<E>`

    - #### descendingIterator

          public java.util.Iterator<E> descendingIterator()

      Specified by:
        `descendingIterator` in interface `java.util.NavigableSet<E>`

    - #### subSet

          public java.util.NavigableSet<E> subSet(E fromElement,
                                         boolean fromInclusive,
                                         E toElement,
                                         boolean toInclusive)

      Specified by:
        `subSet` in interface `java.util.NavigableSet<E>`

    - #### standardSubSet

          @Beta
          protected java.util.NavigableSet<E> standardSubSet(E fromElement,
                                                      boolean fromInclusive,
                                                      E toElement,
                                                      boolean toInclusive)

      A sensible definition of `subSet(Object, boolean, Object, boolean)` in terms of the `headSet` and `tailSet` methods. In many cases, you may wish to override `subSet(Object, boolean, Object, boolean)` to forward to this implementation.

    - #### standardSubSet

          protected java.util.SortedSet<E> standardSubSet(E fromElement,
                                              E toElement)

      A sensible definition of `ForwardingSortedSet.subSet(Object, Object)` in terms of the `subSet(Object, boolean, Object, boolean)` method. If you override `subSet(Object, boolean, Object, boolean)`, you may wish to override `ForwardingSortedSet.subSet(Object, Object)` to forward to this implementation.
      Overrides:
        `standardSubSet` in class `ForwardingSortedSet<E>`

    - #### headSet

          public java.util.NavigableSet<E> headSet(E toElement,
                                          boolean inclusive)

      Specified by:
        `headSet` in interface `java.util.NavigableSet<E>`

    - #### standardHeadSet

          protected java.util.SortedSet<E> standardHeadSet(E toElement)

      A sensible definition of `ForwardingSortedSet.headSet(Object)` in terms of the `headSet(Object, boolean)` method. If you override `headSet(Object, boolean)`, you may wish to override `ForwardingSortedSet.headSet(Object)` to forward to this implementation.

    - #### tailSet

          public java.util.NavigableSet<E> tailSet(E fromElement,
                                          boolean inclusive)

      Specified by:
        `tailSet` in interface `java.util.NavigableSet<E>`

    - #### standardTailSet

          protected java.util.SortedSet<E> standardTailSet(E fromElement)

      A sensible definition of `ForwardingSortedSet.tailSet(Object)` in terms of the `tailSet(Object, boolean)` method. If you override `tailSet(Object, boolean)`, you may wish to override `ForwardingSortedSet.tailSet(Object)` to forward to this implementation.