Package com.usatiuk.objects.iterators
Interface CloseableKvIterator<K extends Comparable<? super K>,V>
- Type Parameters:
K- the type of the keysV- the type of the values
- All Superinterfaces:
AutoCloseable,Iterator<org.apache.commons.lang3.tuple.Pair<K,V>>
- All Known Implementing Classes:
JMapIterator,KeyPredicateKvIterator,MappingKvIterator,MergingKvIterator,NavigableMapKvIterator,ReversedKvIterator,ReversibleKvIterator,TombstoneSkippingIterator
public interface CloseableKvIterator<K extends Comparable<? super K>,V>
extends Iterator<org.apache.commons.lang3.tuple.Pair<K,V>>, AutoCloseable
An iterator over key-value pairs that can be closed and supports peek and skip operations, in both directions.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanhasPrev()Checks if there is a previous element in the reverse direction.Returns the upcoming key in the forward direction without advancing the iterator.Checks if there is a next element in the forward direction.prev()Returns the key-value pair in the reverse direction, and advances the iterator.default CloseableKvIterator<K, V> reversed()Returns a reversed iterator that iterates in the reverse direction.voidskip()Skips the next element in the forward direction.voidskipPrev()Skips the previous element in the reverse direction.Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
peekNextKey
K peekNextKey()Returns the upcoming key in the forward direction without advancing the iterator.- Returns:
- the current key
- Throws:
IllegalStateException- if there is no next element
-
skip
void skip()Skips the next element in the forward direction.- Throws:
IllegalStateException- if there is no next element
-
peekPrevKey
K peekPrevKey()Checks if there is a next element in the forward direction.- Returns:
- true if there is a next element, false otherwise
- Throws:
IllegalStateException- if there is no next element
-
prev
Returns the key-value pair in the reverse direction, and advances the iterator.- Returns:
- the previous key-value pair
- Throws:
IllegalStateException- if there is no previous element
-
hasPrev
boolean hasPrev()Checks if there is a previous element in the reverse direction.- Returns:
- true if there is a previous element, false otherwise
-
skipPrev
void skipPrev()Skips the previous element in the reverse direction.- Throws:
IllegalStateException- if there is no previous element
-
reversed
Returns a reversed iterator that iterates in the reverse direction.- Returns:
- a new CloseableKvIterator that iterates in the reverse direction
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-