Trait sanakirja_core::btree::BTreePage
source · pub trait BTreePage<K: ?Sized, V: ?Sized>: Sized {
type Cursor: Clone + Copy + Debug;
Show 15 methods
// Required methods
fn is_empty(c: &Self::Cursor) -> bool;
fn is_init(c: &Self::Cursor) -> bool;
fn cursor_before(p: &CowPage) -> Self::Cursor;
fn cursor_after(p: &CowPage) -> Self::Cursor;
fn move_next(c: &mut Self::Cursor) -> bool;
fn move_prev(c: &mut Self::Cursor) -> bool;
fn current<'a, T: LoadPage>(
txn: &T,
p: Page<'a>,
c: &Self::Cursor
) -> Option<(&'a K, &'a V, u64)>;
fn left_child(p: Page<'_>, c: &Self::Cursor) -> u64;
fn right_child(p: Page<'_>, c: &Self::Cursor) -> u64;
fn set_cursor<'a, T: LoadPage>(
txn: &'a T,
page: Page<'_>,
c: &mut Self::Cursor,
k0: &K,
v0: Option<&V>
) -> Result<(&'a K, &'a V, u64), usize>;
fn split_at(c: &Self::Cursor) -> (Self::Cursor, Self::Cursor);
// Provided methods
fn cursor_first(p: &CowPage) -> Self::Cursor { ... }
fn cursor_last(p: &CowPage) -> Self::Cursor { ... }
fn next<'b, T: LoadPage>(
txn: &T,
p: Page<'b>,
c: &mut Self::Cursor
) -> Option<(&'b K, &'b V, u64)> { ... }
fn prev<'b, T: LoadPage>(
txn: &T,
p: Page<'b>,
c: &mut Self::Cursor
) -> Option<(&'b K, &'b V, u64)> { ... }
}
Required Associated Types§
Required Methods§
sourcefn cursor_before(p: &CowPage) -> Self::Cursor
fn cursor_before(p: &CowPage) -> Self::Cursor
Returns a cursor set before the first element of the page (i.e. set to -1).
sourcefn cursor_after(p: &CowPage) -> Self::Cursor
fn cursor_after(p: &CowPage) -> Self::Cursor
Returns a cursor set after the last element of the page (i.e. to element n)
sourcefn move_next(c: &mut Self::Cursor) -> bool
fn move_next(c: &mut Self::Cursor) -> bool
Move the cursor to the next position. Returns whether the
cursor was actually moved (i.e. true
if and only if the
cursor isn’t already after the last element).
sourcefn move_prev(c: &mut Self::Cursor) -> bool
fn move_prev(c: &mut Self::Cursor) -> bool
Move the cursor to the previous position. Returns whether the
cursor was actually moved (i.e. true
if and only if the
cursor isn’t strictly before the page).
sourcefn current<'a, T: LoadPage>(
txn: &T,
p: Page<'a>,
c: &Self::Cursor
) -> Option<(&'a K, &'a V, u64)>
fn current<'a, T: LoadPage>( txn: &T, p: Page<'a>, c: &Self::Cursor ) -> Option<(&'a K, &'a V, u64)>
Returns the current element, if the cursor is pointing at one.
sourcefn left_child(p: Page<'_>, c: &Self::Cursor) -> u64
fn left_child(p: Page<'_>, c: &Self::Cursor) -> u64
Returns the left child of the entry pointed to by the cursor.
sourcefn right_child(p: Page<'_>, c: &Self::Cursor) -> u64
fn right_child(p: Page<'_>, c: &Self::Cursor) -> u64
Returns the right child of the entry pointed to by the cursor.
sourcefn set_cursor<'a, T: LoadPage>(
txn: &'a T,
page: Page<'_>,
c: &mut Self::Cursor,
k0: &K,
v0: Option<&V>
) -> Result<(&'a K, &'a V, u64), usize>
fn set_cursor<'a, T: LoadPage>( txn: &'a T, page: Page<'_>, c: &mut Self::Cursor, k0: &K, v0: Option<&V> ) -> Result<(&'a K, &'a V, u64), usize>
Sets the cursor to the last element less than or equal to k0
if v0.is_none()
, and to (k0, v0)
if v0.is_some()
. If a
match is found (on k0
only if v0.is_none()
, on (k0, v0)
else), return the match along with the right child.
Else (in the Err
case of the Result
), return the position
at which (k0, v0)
can be inserted.
Provided Methods§
sourcefn cursor_first(p: &CowPage) -> Self::Cursor
fn cursor_first(p: &CowPage) -> Self::Cursor
Returns a cursor set to the first element of the page (i.e. 0). If the page is empty, the returned cursor might be empty.
sourcefn cursor_last(p: &CowPage) -> Self::Cursor
fn cursor_last(p: &CowPage) -> Self::Cursor
Returns a cursor set to the last element of the page. If the
cursor is empty, this is the same as cursor_before
.