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 TypeMethodDescriptionvoidclose()protected booleanhasImpl()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 KpeekImpl()Fills the next element in the iterator, depending on the current direction.protected voidreverse()Reverses the current direction of the iterator.protected voidskipImpl()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, skipPrevMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.usatiuk.objects.iterators.CloseableKvIterator
reversedMethods 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:ReversibleKvIteratorReverses the current direction of the iterator.- Specified by:
reversein classReversibleKvIterator<K extends Comparable<K>,V>
-
peekImpl
Description copied from class:ReversibleKvIteratorFills the next element in the iterator, depending on the current direction.- Specified by:
peekImplin classReversibleKvIterator<K extends Comparable<K>,V>
-
skipImpl
protected void skipImpl()Description copied from class:ReversibleKvIteratorSkips the next element in the iterator, depending on the current direction.- Specified by:
skipImplin classReversibleKvIterator<K extends Comparable<K>,V>
-
hasImpl
protected boolean hasImpl()Description copied from class:ReversibleKvIteratorChecks if there is a next element in the iterator, depending on the current direction.- Specified by:
hasImplin classReversibleKvIterator<K extends Comparable<K>,V> - Returns:
- true if there is a next element, false otherwise
-
nextImpl
Description copied from class:ReversibleKvIteratorReturns the next element in the iterator, depending on the current direction.- Specified by:
nextImplin classReversibleKvIterator<K extends Comparable<K>,V> - Returns:
- the next element
-
close
public void close() -
toString
-