Class ForwardingNavigableSet<E>
- All Implemented Interfaces:
Iterable<E>, Collection<E>, NavigableSet<E>, SequencedCollection<E>, SequencedSet<E>, Set<E>, SortedSet<E>
- Direct Known Subclasses:
ForwardingNavigableSet.StandardDescendingSet
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(Collection), 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.
default method warning: This class does not forward calls to
default methods. Instead, it inherits their default implementations. When those implementations
invoke methods, they invoke methods on the ForwardingNavigableSet.
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 ClassesModifier and TypeClassDescriptionprotected classA sensible implementation ofNavigableSet.descendingSet()in terms of the other methods ofNavigableSet, notably includingNavigableSet.descendingIterator(). -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor for use by subclasses. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract NavigableSet<E> delegate()Returns the backing delegate instance that methods are forwarded to.pollLast()protected EstandardCeiling(E e) protected Eprotected EstandardFloor(E e) A sensible definition offloor(E)in terms of thedescendingIteratormethod ofheadSet(Object, boolean).standardHeadSet(E toElement) A sensible definition ofForwardingSortedSet.headSet(Object)in terms of theheadSet(Object, boolean)method.protected EstandardHigher(E e) protected Eprotected EstandardLower(E e) A sensible definition oflower(E)in terms of thedescendingIteratormethod ofheadSet(Object, boolean).protected EA sensible definition ofpollFirst()in terms of theiteratormethod.protected EA sensible definition ofpollLast()in terms of thedescendingIteratormethod.protected NavigableSet<E> standardSubSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) A sensible definition ofsubSet(Object, boolean, Object, boolean)in terms of theheadSetandtailSetmethods.standardSubSet(E fromElement, E toElement) A sensible definition ofForwardingSortedSet.subSet(Object, Object)in terms of thesubSet(Object, boolean, Object, boolean)method.standardTailSet(E fromElement) A sensible definition ofForwardingSortedSet.tailSet(Object)in terms of thetailSet(Object, boolean)method.Methods inherited from class ForwardingSortedSet
comparator, first, headSet, last, standardContains, standardRemove, subSet, tailSetMethods inherited from class ForwardingSet
equals, hashCode, standardEquals, standardHashCode, standardRemoveAllMethods inherited from class ForwardingCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContainsAll, standardIsEmpty, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArrayMethods inherited from class ForwardingObject
toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface NavigableSet
headSet, iterator, removeFirst, removeLast, reversed, subSet, tailSetMethods inherited from interface Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArrayMethods inherited from interface SortedSet
addFirst, addLast, comparator, first, getFirst, getLast, last, spliterator
-
Constructor Details
-
ForwardingNavigableSet
protected ForwardingNavigableSet()Constructor for use by subclasses.
-
-
Method Details
-
delegate
Description copied from class:ForwardingObjectReturns 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 asForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.- Specified by:
delegatein classForwardingSortedSet<E>
-
lower
- Specified by:
lowerin interfaceNavigableSet<E>
-
standardLower
A sensible definition oflower(E)in terms of thedescendingIteratormethod ofheadSet(Object, boolean). If you overrideheadSet(Object, boolean), you may wish to overridelower(E)to forward to this implementation. -
floor
- Specified by:
floorin interfaceNavigableSet<E>
-
standardFloor
A sensible definition offloor(E)in terms of thedescendingIteratormethod ofheadSet(Object, boolean). If you overrideheadSet(Object, boolean), you may wish to overridefloor(E)to forward to this implementation. -
ceiling
- Specified by:
ceilingin interfaceNavigableSet<E>
-
standardCeiling
A sensible definition ofceiling(E)in terms of theiteratormethod oftailSet(Object, boolean). If you overridetailSet(Object, boolean), you may wish to overrideceiling(E)to forward to this implementation. -
higher
- Specified by:
higherin interfaceNavigableSet<E>
-
standardHigher
A sensible definition ofhigher(E)in terms of theiteratormethod oftailSet(Object, boolean). If you overridetailSet(Object, boolean), you may wish to overridehigher(E)to forward to this implementation. -
pollFirst
- Specified by:
pollFirstin interfaceNavigableSet<E>
-
standardPollFirst
A sensible definition ofpollFirst()in terms of theiteratormethod. If you overrideForwardingCollection.iterator()you may wish to overridepollFirst()to forward to this implementation. -
pollLast
- Specified by:
pollLastin interfaceNavigableSet<E>
-
standardPollLast
A sensible definition ofpollLast()in terms of thedescendingIteratormethod. If you overridedescendingIterator()you may wish to overridepollLast()to forward to this implementation. -
standardFirst
-
standardLast
-
descendingSet
- Specified by:
descendingSetin interfaceNavigableSet<E>
-
descendingIterator
- Specified by:
descendingIteratorin interfaceNavigableSet<E>
-
subSet
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) - Specified by:
subSetin interfaceNavigableSet<E>
-
standardSubSet
@Beta protected NavigableSet<E> standardSubSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) A sensible definition ofsubSet(Object, boolean, Object, boolean)in terms of theheadSetandtailSetmethods. In many cases, you may wish to overridesubSet(Object, boolean, Object, boolean)to forward to this implementation. -
standardSubSet
A sensible definition ofForwardingSortedSet.subSet(Object, Object)in terms of thesubSet(Object, boolean, Object, boolean)method. If you overridesubSet(Object, boolean, Object, boolean), you may wish to overrideForwardingSortedSet.subSet(Object, Object)to forward to this implementation.- Overrides:
standardSubSetin classForwardingSortedSet<E>
-
headSet
- Specified by:
headSetin interfaceNavigableSet<E>
-
standardHeadSet
A sensible definition ofForwardingSortedSet.headSet(Object)in terms of theheadSet(Object, boolean)method. If you overrideheadSet(Object, boolean), you may wish to overrideForwardingSortedSet.headSet(Object)to forward to this implementation. -
tailSet
- Specified by:
tailSetin interfaceNavigableSet<E>
-
standardTailSet
A sensible definition ofForwardingSortedSet.tailSet(Object)in terms of thetailSet(Object, boolean)method. If you overridetailSet(Object, boolean), you may wish to overrideForwardingSortedSet.tailSet(Object)to forward to this implementation.
-