Interface Cursor<K,V>
-
- Type Parameters:
K- Type of the record's keyV- Type of the record's value
- All Superinterfaces:
AutoCloseable,Closeable,SequentialCursor<K,V>
- All Known Implementing Classes:
EmptyCursor
public interface Cursor<K,V> extends SequentialCursor<K,V>
Sequential cursor extended with navigation methods.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default booleanpositionToIndex(int index)Positions the cursor to the specified index within the tree.default booleanpositionToKey(K key)Positions the cursor to the provided key if it exists in the tree.default booleanpositionToKeyOrNext(K key)Positions the cursor to the provided key if it exists in the tree, or else the lesser key greater than the provided key in the tree.default booleanpositionToLastKey()Positions the cursor to the last key in the tree.default booleanprevious()Moves this cursor to the previous record in the tree.
-
-
-
Method Detail
-
previous
default boolean previous()
Moves this cursor to the previous record in the tree.- Returns:
trueif the cursor has moved to the previous record,falseif no next record exists leaving cursor in undefined state.
-
positionToKey
default boolean positionToKey(K key)
Positions the cursor to the provided key if it exists in the tree.Positioning the cursor is required before calling
SequentialCursor.isValid().- Parameters:
key- the key where to position the cursor- Returns:
trueif the cursor could be positioned to the key,falseotherwise
-
positionToKeyOrNext
default boolean positionToKeyOrNext(K key)
Positions the cursor to the provided key if it exists in the tree, or else the lesser key greater than the provided key in the tree.Positioning the cursor is required before calling
SequentialCursor.isValid().- Parameters:
key- the key where to position the cursor- Returns:
trueif the cursor could be positioned to the key or the next one,falseotherwise
-
positionToLastKey
default boolean positionToLastKey()
Positions the cursor to the last key in the tree.Positioning the cursor is required before calling
SequentialCursor.isValid().- Returns:
trueif the cursor could be positioned to the last key,falseotherwise
-
positionToIndex
default boolean positionToIndex(int index)
Positions the cursor to the specified index within the tree. Implementations may take advantage of optimizations provided by the underlying storage, such as counted B-Trees.Positioning the cursor is required before calling
SequentialCursor.isValid().- Parameters:
index- the index where the cursor should be positioned, (0 is the first record).- Returns:
trueif the cursor could be positioned to the index,falseotherwise
-
-