Package com.usatiuk.objects.iterators
Class MergingKvIterator<K extends Comparable<K>,V>
java.lang.Object
com.usatiuk.objects.iterators.ReversibleKvIterator<K,V>
com.usatiuk.objects.iterators.MergingKvIterator<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 merging key-value iterator that combines multiple iterators into a single iterator.
-
Field Summary
Fields inherited from class com.usatiuk.objects.iterators.ReversibleKvIterator
_goingForward
-
Constructor Summary
ConstructorsConstructorDescriptionMergingKvIterator
(IteratorStart startType, K startKey, CloseableKvIterator<K, V>... iterators) Constructs a MergingKvIterator with the specified start type, start key, and array of iterators.MergingKvIterator
(IteratorStart startType, K startKey, List<CloseableKvIterator<K, V>> iterators) Constructs a MergingKvIterator with the specified start type, start key, and list of iterators. -
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
-
MergingKvIterator
public MergingKvIterator(IteratorStart startType, K startKey, List<CloseableKvIterator<K, V>> iterators) Constructs a MergingKvIterator with the specified start type, start key, and list of iterators. The iterators have priority based on their order in the list: if two iterators have the same key, the one that is in the beginning of the list will be used.- Parameters:
startType
- the starting position relative to the startKeystartKey
- the starting keyiterators
- the list of iterators to merge
-
MergingKvIterator
@SafeVarargs public MergingKvIterator(IteratorStart startType, K startKey, CloseableKvIterator<K, V>... iterators) Constructs a MergingKvIterator with the specified start type, start key, and array of iterators. The iterators have priority based on their order in the array: if two iterators have the same key, the one that is in the beginning of the array will be used.- Parameters:
startType
- the starting position relative to the startKeystartKey
- the starting keyiterators
- the array of iterators to merge
-
-
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
-