Struct Cursor

Source
pub struct Cursor<K: Key> { /* private fields */ }
Expand description

Cursor points to a key value pair in the tree. Not like Iterator, it can move to next or prev.

Implementations§

Source§

impl<'k, K: Key + 'k> Cursor<K>

Source

pub fn key(&self) -> &K

Get the key of the cursor.

Source

pub fn first<'b, S: NodeStore<K = K>>( tree: &'b BPlusTree<S>, ) -> Option<(Self, &'b S::V)>
where 'k: 'b,

Create a Cursor pointing to the first key-value pair in the tree.

Source

pub fn last<'b, S: NodeStore<K = K>>( tree: &'b BPlusTree<S>, ) -> Option<(Self, &'b S::V)>
where 'k: 'b,

Create a Cursor pointing to the last key-value pair in the tree. If the key for self is deleted, then this returns the cursor for the key value pair just larger than the deleted key.

Source

pub fn prev<'a, 'b, S: NodeStore<K = K>>( &'a self, tree: &'b BPlusTree<S>, ) -> Option<Self>

Get the Cursor points to the prev key-value pair. If the key for self is deleted, then this returns the cursor for the key value pair just under the deleted key.

Source

pub fn prev_with_value<'a, 'b, S: NodeStore<K = K>>( &'a self, tree: &'b BPlusTree<S>, ) -> Option<(Self, &'b S::V)>
where 'k: 'b,

Get the Cursor points to the prev key-value pair, also with a reference to the value. This is faster than first prev, then value.

Source

pub fn next<'a, 'b, S: NodeStore<K = K>>( &'a self, tree: &'b BPlusTree<S>, ) -> Option<Self>

Get the Cursor points to the next key-value pair. If the key for self is deleted, then this returns the cursor for the key value pair just larger than the deleted key.

Source

pub fn next_with_value<'a, 'b, S: NodeStore<K = K>>( &'a self, tree: &'b BPlusTree<S>, ) -> Option<(Self, &'b S::V)>
where 'k: 'b,

Get the Cursor points to the next key-value pair, also with a reference to the value.

Source

pub fn exists<'a, 'b, S: NodeStore<K = K>>( &'a self, tree: &'b BPlusTree<S>, ) -> bool

whether current cursor is still valid

Source

pub fn value<'a, 'b, S: NodeStore<K = K>>( &'a self, tree: &'b BPlusTree<S>, ) -> Option<&'b S::V>
where 'k: 'b,

get the value attached to cursor, if the underlying key is deleted, this returns None

Trait Implementations§

Source§

impl<K: Clone + Key> Clone for Cursor<K>

Source§

fn clone(&self) -> Cursor<K>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug + Key> Debug for Cursor<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: Copy + Key> Copy for Cursor<K>

Auto Trait Implementations§

§

impl<K> Freeze for Cursor<K>
where K: Freeze,

§

impl<K> RefUnwindSafe for Cursor<K>
where K: RefUnwindSafe,

§

impl<K> Send for Cursor<K>
where K: Send,

§

impl<K> Sync for Cursor<K>
where K: Sync,

§

impl<K> Unpin for Cursor<K>
where K: Unpin,

§

impl<K> UnwindSafe for Cursor<K>
where K: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.