Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bidirectional Iterators #588

Merged
merged 17 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions include/splinterdb/splinterdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,36 @@ splinterdb_iterator_deinit(splinterdb_iterator *iter);

// Checks that the iterator status is OK (no errors) and that get_current()
// will succeed. If false, there are two possibilities:
// 1. Iterator has passed the final item. In this case, status() == 0
// 1. Iterator is out of bounds. In this case, status() == 0
// 2. Iterator has encountered an error. In this case, status() != 0
_Bool
splinterdb_iterator_valid(splinterdb_iterator *iter);

// Attempts to advance the iterator to the next item.
/*
* splinterdb_iterator_can_next --
* splinterdb_iterator_can_prev --
*
* Knowing the iterator is invalid does not provide enough information to
* determine if next and prev are safe operations.
*
* These functions provide granular information on which operations are safe.
* splinterdb_iterator_can_next == TRUE <-> splinterdb_iterator_next is safe
* splinterdb_iterator_can_prev == TRUE <-> splinterdb_iterator_prev is safe
*/
_Bool
splinterdb_iterator_can_prev(splinterdb_iterator *iter);

_Bool
splinterdb_iterator_can_next(splinterdb_iterator *iter);

// Moves the iterator to the previous item.
// Precondition for calling: splinterdb_iterator_can_prev() returns TRUE
// Any error will cause valid() == false and be visible with status()
void
splinterdb_iterator_prev(splinterdb_iterator *iter);

// Moves the iterator to the next item.
// Precondition for calling: splinterdb_iterator_can_next() returns TRUE
// Any error will cause valid() == false and be visible with status()
void
splinterdb_iterator_next(splinterdb_iterator *iter);
Expand Down
Loading