E - the type of element in the setpublic class DescendingSet<E> extends Object implements NavigableSet<E>
NavigableSet that is a view of another set, but in opposite (descending) order.
Most operations are reversed. For example first() returns the
last item in the underlying set, iterator() visits
elements in descending order (and descendingIterator() visits them in ascending order!),
etc.
This implementation is designed to be used to implement NavigableSet.descendingSet().
The underlying set must implement all other interface methods without using this
implementation. For example, you can't use a DescendingSet to help you implement a
descending iterator since the DescendingSet relies on your implementation of
NavigableSet.descendingIterator() to implement its iterator() method.
| Constructor and Description |
|---|
DescendingSet(NavigableSet<E> base)
Constructs a new descending view of the specified set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
boolean |
addAll(Collection<? extends E> c) |
protected NavigableSet<E> |
base() |
E |
ceiling(E e) |
void |
clear() |
Comparator<? super E> |
comparator() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
Iterator<E> |
descendingIterator() |
NavigableSet<E> |
descendingSet() |
boolean |
equals(Object o) |
E |
first() |
E |
floor(E e) |
int |
hashCode() |
NavigableSet<E> |
headSet(E toElement) |
NavigableSet<E> |
headSet(E toElement,
boolean inclusive) |
E |
higher(E e) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
E |
last() |
E |
lower(E e) |
E |
pollFirst() |
E |
pollLast() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
NavigableSet<E> |
subSet(E fromElement,
boolean fromInclusive,
E toElement,
boolean toInclusive) |
NavigableSet<E> |
subSet(E fromElement,
E toElement) |
NavigableSet<E> |
tailSet(E fromElement) |
NavigableSet<E> |
tailSet(E fromElement,
boolean inclusive) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitspliteratorparallelStream, removeIf, streampublic DescendingSet(NavigableSet<E> base)
base - the underlying setprotected NavigableSet<E> base()
public Comparator<? super E> comparator()
comparator in interface SortedSet<E>public boolean add(E e)
public boolean addAll(Collection<? extends E> c)
public void clear()
public boolean contains(Object o)
public boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in interface Set<E>public boolean isEmpty()
public boolean remove(Object o)
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public int size()
public Object[] toArray()
public <T> T[] toArray(T[] a)
public E ceiling(E e)
ceiling in interface NavigableSet<E>public Iterator<E> descendingIterator()
descendingIterator in interface NavigableSet<E>public NavigableSet<E> descendingSet()
descendingSet in interface NavigableSet<E>public E floor(E e)
floor in interface NavigableSet<E>public NavigableSet<E> headSet(E toElement)
public NavigableSet<E> headSet(E toElement, boolean inclusive)
headSet in interface NavigableSet<E>public E higher(E e)
higher in interface NavigableSet<E>public E lower(E e)
lower in interface NavigableSet<E>public E pollFirst()
pollFirst in interface NavigableSet<E>public E pollLast()
pollLast in interface NavigableSet<E>public NavigableSet<E> subSet(E fromElement, E toElement)
public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
subSet in interface NavigableSet<E>public NavigableSet<E> tailSet(E fromElement)
public NavigableSet<E> tailSet(E fromElement, boolean inclusive)
tailSet in interface NavigableSet<E>public boolean equals(Object o)
public int hashCode()