Package com.usatiuk.objects.iterators
Class KeyPredicateKvIterator<K extends Comparable<K>,V>
java.lang.Object
com.usatiuk.objects.iterators.ReversibleKvIterator<K,V>
com.usatiuk.objects.iterators.KeyPredicateKvIterator<K,V>
- Type Parameters:
K
- the type of the keysV
- the type of the values
- All Implemented Interfaces:
CloseableKvIterator<K,
,V> AutoCloseable
,Iterator<org.apache.commons.lang3.tuple.Pair<K,
V>>
A key-value iterator that filters keys based on a predicate.
-
Field Summary
Fields inherited from class com.usatiuk.objects.iterators.ReversibleKvIterator
_goingForward
-
Constructor Summary
ConstructorsConstructorDescriptionKeyPredicateKvIterator
(CloseableKvIterator<K, V> backing, IteratorStart start, K startKey, Function<K, Boolean> filter) Constructs a KeyPredicateKvIterator with the specified backing iterator, start position, and filter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected boolean
hasImpl()
Checks if there is a next element in the iterator, depending on the current direction.nextImpl()
Returns the next element in the iterator, depending on the current direction.protected K
peekImpl()
Fills the next element in the iterator, depending on the current direction.protected void
reverse()
Reverses the current direction of the iterator.protected void
skipImpl()
Skips the next element in the iterator, depending on the current direction.toString()
Methods inherited from class com.usatiuk.objects.iterators.ReversibleKvIterator
hasNext, hasPrev, next, peekNextKey, peekPrevKey, prev, skip, skipPrev
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.usatiuk.objects.iterators.CloseableKvIterator
reversed
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
KeyPredicateKvIterator
public KeyPredicateKvIterator(CloseableKvIterator<K, V> backing, IteratorStart start, K startKey, Function<K, Boolean> filter) Constructs a KeyPredicateKvIterator with the specified backing iterator, start position, and filter.- Parameters:
backing
- the backing iteratorstart
- the starting position relative to the startKeystartKey
- the starting keyfilter
- the filter function to apply to keys. Only keys for which this function returns true will be included in the iteration.
-
-
Method Details
-
reverse
protected void reverse()Description copied from class:ReversibleKvIterator
Reverses the current direction of the iterator.- Specified by:
reverse
in classReversibleKvIterator<K extends Comparable<K>,
V>
-
peekImpl
Description copied from class:ReversibleKvIterator
Fills the next element in the iterator, depending on the current direction.- Specified by:
peekImpl
in classReversibleKvIterator<K extends Comparable<K>,
V>
-
skipImpl
protected void skipImpl()Description copied from class:ReversibleKvIterator
Skips the next element in the iterator, depending on the current direction.- Specified by:
skipImpl
in classReversibleKvIterator<K extends Comparable<K>,
V>
-
hasImpl
protected boolean hasImpl()Description copied from class:ReversibleKvIterator
Checks if there is a next element in the iterator, depending on the current direction.- Specified by:
hasImpl
in classReversibleKvIterator<K extends Comparable<K>,
V> - Returns:
- true if there is a next element, false otherwise
-
nextImpl
Description copied from class:ReversibleKvIterator
Returns the next element in the iterator, depending on the current direction.- Specified by:
nextImpl
in classReversibleKvIterator<K extends Comparable<K>,
V> - Returns:
- the next element
-
close
public void close() -
toString
-