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 boolean
positionToIndex(int index)
Positions the cursor to the specified index within the tree.default boolean
positionToKey(K key)
Positions the cursor to the provided key if it exists in the tree.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.default boolean
positionToLastKey()
Positions the cursor to the last key in the tree.default boolean
previous()
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:
true
if the cursor has moved to the previous record,false
if 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:
true
if the cursor could be positioned to the key,false
otherwise
-
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:
true
if the cursor could be positioned to the key or the next one,false
otherwise
-
positionToLastKey
default boolean positionToLastKey()
Positions the cursor to the last key in the tree.Positioning the cursor is required before calling
SequentialCursor.isValid()
.- Returns:
true
if the cursor could be positioned to the last key,false
otherwise
-
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:
true
if the cursor could be positioned to the index,false
otherwise
-
-