Interface SequentialCursor<K,V>
- Type Parameters:
K- Type of the record's keyV- Type of the record's value
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Subinterfaces:
Cursor<K,V>
- All Known Implementing Classes:
EmptyCursor
Cursor extended with navigation methods.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()default voiddelete()Deletes the record on which this cursor is currently positioned.getKey()Returns the key of the record on which this cursor is currently positioned.default VgetValue()Returns the value of the record on which this cursor is currently positioned.booleanisValid()Check whether this cursor is currently pointing to a valid record.booleannext()Moves this cursor to the next record in the tree.
-
Method Details
-
next
boolean next()Moves this cursor to the next record in the tree.No data is available before calling
next()on a new cursor.- Returns:
trueif the cursor has moved to the next record,falseif no next record exists leaving cursor in undefined state.
-
isValid
boolean isValid()Check whether this cursor is currently pointing to a valid record.Before calling
isValid()the cursor must be positioned by callingnext().- Returns:
trueif the cursor is pointing to a valid entry,falseif cursor is not pointing to a valid entry
-
getKey
Returns the key of the record on which this cursor is currently positioned.- Returns:
- the current record's key.
- Throws:
NoSuchElementException- if the cursor is not valid.
-
getValue
Returns the value of the record on which this cursor is currently positioned.- Returns:
- the current record's value.
- Throws:
NoSuchElementException- if the cursor is not valid.
-
delete
Deletes the record on which this cursor is currently positioned. This method does not alter the position of the cursor. In particular,next()must be called in order to point to the next record. The behavior of methodsgetKey()andgetValue()after this method returns is undefined.- Throws:
NoSuchElementException- if the cursor is not valid.UnsupportedOperationException- if the cursor implementation does not support updates.
-
close
default void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-