E
- element type of this setW
- element type of the wrapped setpublic class ConvertedNavigableSet<E,W> extends AbstractNavigableSet<E>
NavigableSet
using a strictly invertable Converter
.
Supplied Converter
s may throw ClassCastException
or IllegalArgumentException
if given an objects whose runtime type does not match the expected type.
bounds
Constructor and Description |
---|
ConvertedNavigableSet(NavigableSet<W> set,
Converter<E,W> converter)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E obj) |
void |
clear() |
Comparator<? super E> |
comparator() |
boolean |
contains(Object obj) |
protected NavigableSet<E> |
createSubSet(boolean reverse,
Bounds<E> newBounds)
Create a (possibly reversed) view of this instance with (possibly) tighter lower and/or upper bounds.
|
Converter<E,W> |
getConverter()
Get the
Converter associated with this instance. |
NavigableSet<W> |
getWrappedNavigableSet()
Get the wrapped
NavigableSet . |
boolean |
isEmpty()
Overridden in
AbstractIterationSet to minimize the use of AbstractIterationSet.size() . |
Iterator<E> |
iterator() |
boolean |
remove(Object obj)
Removes the given element from this set if it is present.
|
protected E |
searchAbove(E elem,
boolean inclusive)
Search for a higher element.
|
protected E |
searchBelow(E elem,
boolean inclusive)
Search for a lower element.
|
int |
size()
Calculate size.
|
Spliterator<E> |
spliterator()
Overridden in
AbstractIterationSet to avoid the use of AbstractIterationSet.size() . |
ceiling, descendingIterator, descendingSet, first, floor, getComparator, headSet, headSet, higher, isWithinLowerBound, isWithinUpperBound, last, lower, pollFirst, pollLast, subSet, subSet, tailSet, tailSet
equals, hashCode, toArray, toArray
removeAll
addAll, containsAll, retainAll, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
parallelStream, removeIf, stream
public ConvertedNavigableSet(NavigableSet<W> set, Converter<E,W> converter)
set
- wrapped setconverter
- element converterIllegalArgumentException
- if either parameter is nullpublic NavigableSet<W> getWrappedNavigableSet()
NavigableSet
.NavigableSet
.public Converter<E,W> getConverter()
Converter
associated with this instance.Converter
public Comparator<? super E> comparator()
public boolean contains(Object obj)
contains
in interface Collection<E>
contains
in interface Set<E>
contains
in class AbstractCollection<E>
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in interface NavigableSet<E>
iterator
in interface Set<E>
iterator
in class AbstractCollection<E>
public Spliterator<E> spliterator()
AbstractIterationSet
AbstractIterationSet
to avoid the use of AbstractIterationSet.size()
.spliterator
in interface Iterable<E>
spliterator
in interface Collection<E>
spliterator
in interface Set<E>
spliterator
in interface SortedSet<E>
spliterator
in class AbstractNavigableSet<E>
public boolean add(E obj)
add
in interface Collection<E>
add
in interface Set<E>
add
in class AbstractCollection<E>
public boolean remove(Object obj)
AbstractNavigableSet
The implementation in AbstractNavigableSet
always throws UnsupportedOperationException
.
remove
in interface Collection<E>
remove
in interface Set<E>
remove
in class AbstractNavigableSet<E>
public void clear()
clear
in interface Collection<E>
clear
in interface Set<E>
clear
in class AbstractCollection<E>
public boolean isEmpty()
AbstractIterationSet
AbstractIterationSet
to minimize the use of AbstractIterationSet.size()
.isEmpty
in interface Collection<E>
isEmpty
in interface Set<E>
isEmpty
in class AbstractIterationSet<E>
public int size()
AbstractIterationSet
The implementation in AbstractIterationSet
iterates through all of the elements.
size
in interface Collection<E>
size
in interface Set<E>
size
in class AbstractIterationSet<E>
protected E searchBelow(E elem, boolean inclusive)
AbstractNavigableSet
floor()
and lower()
.
The implementation in AbstractNavigableSet
checks the bounds then returns the first element from a head set.
searchBelow
in class AbstractNavigableSet<E>
elem
- upper limit for searchinclusive
- true if elem
itself is a candidateelem
, or null if not foundprotected E searchAbove(E elem, boolean inclusive)
AbstractNavigableSet
ceiling()
and higher()
.
The implementation in AbstractNavigableSet
checks the bounds then returns the first element from a tail set.
searchAbove
in class AbstractNavigableSet<E>
elem
- lower limit for searchinclusive
- true if elem
itself is a candidateelem
, or null if not foundprotected NavigableSet<E> createSubSet(boolean reverse, Bounds<E> newBounds)
AbstractNavigableSet
newBounds
are consistent with the new ordering (i.e., reversed relative to this instance's ordering if
reverse
is true) and have already been range-checked against this instance's current bounds.createSubSet
in class AbstractNavigableSet<E>
reverse
- whether the new set's ordering should be reversed relative to this instance's orderingnewBounds
- new boundsCopyright © 2022. All rights reserved.