Class ConvertedNavigableSet<E,W>
- Type Parameters:
E
- element type of this setW
- element type of the wrapped set
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,NavigableSet<E>
,Set<E>
,SortedSet<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.
-
Field Summary
Fields inherited from class io.permazen.util.AbstractNavigableSet
bounds
-
Constructor Summary
ConstructorDescriptionConvertedNavigableSet
(NavigableSet<W> set, Converter<E, W> converter) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
clear()
Comparator<? super E>
boolean
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.Get theConverter
associated with this instance.Get the wrappedNavigableSet
.boolean
isEmpty()
Overridden inAbstractIterationSet
to minimize the use ofAbstractIterationSet.size()
.iterator()
boolean
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.Overridden inAbstractIterationSet
to avoid the use ofAbstractIterationSet.size()
.stream()
Methods inherited from class io.permazen.util.AbstractNavigableSet
buildSpliterator, ceiling, descendingIterator, descendingSet, first, floor, getBounds, getComparator, headSet, headSet, higher, isWithinLowerBound, isWithinUpperBound, last, lower, pollFirst, pollLast, subSet, subSet, tailSet, tailSet
Methods inherited from class io.permazen.util.AbstractIterationSet
equals, hashCode, toArray, toArray
Methods inherited from class java.util.AbstractSet
removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, toArray
-
Constructor Details
-
Method Details
-
getConverter
Get theConverter
associated with this instance.- Returns:
- associated
Converter
-
comparator
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Overrides:
contains
in classAbstractCollection<E>
-
iterator
- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in interfaceNavigableSet<E>
- Specified by:
iterator
in interfaceSet<E>
- Specified by:
iterator
in classAbstractIterationSet<E>
-
spliterator
Description copied from class:AbstractIterationSet
Overridden inAbstractIterationSet
to avoid the use ofAbstractIterationSet.size()
.Note: the underlying
CloseableIterator
is not closed when this method is used. Prefer usingAbstractIterationSet.buildSpliterator(java.util.Iterator<E>)
and arranging for the iterator to be closed separately.- Specified by:
spliterator
in interfaceCollection<E>
- Specified by:
spliterator
in interfaceIterable<E>
- Specified by:
spliterator
in interfaceSet<E>
- Specified by:
spliterator
in interfaceSortedSet<E>
- Overrides:
spliterator
in classAbstractIterationSet<E>
-
stream
Description copied from class:AbstractIterationSet
The implementation in
AbstractIterationSet
build a stream from the results fromAbstractIterationSet.iterator()
andbuildSpliterator()
, and marks the iterator for close viaStream.onClose()
.- Specified by:
stream
in interfaceCollection<E>
- Overrides:
stream
in classAbstractIterationSet<E>
-
add
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classAbstractCollection<E>
-
remove
Description copied from class:AbstractNavigableSet
Removes the given element from this set if it is present.The implementation in
AbstractNavigableSet
always throwsUnsupportedOperationException
.- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classAbstractNavigableSet<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Overrides:
clear
in classAbstractCollection<E>
-
isEmpty
public boolean isEmpty()Description copied from class:AbstractIterationSet
Overridden inAbstractIterationSet
to minimize the use ofAbstractIterationSet.size()
.- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceSet<E>
- Overrides:
isEmpty
in classAbstractIterationSet<E>
-
size
public int size()Description copied from class:AbstractIterationSet
Calculate size.The implementation in
AbstractIterationSet
iterates through all of the elements.- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Overrides:
size
in classAbstractIterationSet<E>
-
searchBelow
Description copied from class:AbstractNavigableSet
Search for a lower element. Used to implementfloor()
andlower()
.The implementation in
AbstractNavigableSet
checks the bounds then returns the first element from a head set.- Overrides:
searchBelow
in classAbstractNavigableSet<E>
- Parameters:
elem
- upper limit for searchinclusive
- true ifelem
itself is a candidate- Returns:
- highest element below
elem
, or null if not found
-
searchAbove
Description copied from class:AbstractNavigableSet
Search for a higher element. Used to implementceiling()
andhigher()
.The implementation in
AbstractNavigableSet
checks the bounds then returns the first element from a tail set.- Overrides:
searchAbove
in classAbstractNavigableSet<E>
- Parameters:
elem
- lower limit for searchinclusive
- true ifelem
itself is a candidate- Returns:
- lowest element above
elem
, or null if not found
-
createSubSet
Description copied from class:AbstractNavigableSet
Create a (possibly reversed) view of this instance with (possibly) tighter lower and/or upper bounds. ThenewBounds
are consistent with the new ordering (i.e., reversed relative to this instance's ordering ifreverse
is true) and have already been range-checked against this instance's current bounds.- Specified by:
createSubSet
in classAbstractNavigableSet<E>
- Parameters:
reverse
- whether the new set's ordering should be reversed relative to this instance's orderingnewBounds
- new bounds- Returns:
- restricted and/or reversed view of this instance