Skip to main content

NavCursor

Struct NavCursor 

Source
pub struct NavCursor<'a, K, V, S> { /* private fields */ }
Expand description

A graph-navigational cursor that sits directly on a tree node, exposing raw topography traversal and augmented subtree metrics.

Unlike a standard, linear cursor that tracks abstract gaps between elements, the NavCursor provides power-users with low-level access to the tree’s actual graph edges (left, right, and parent) along with the node’s sorted sequence links (next, prev).

§The State Model: Advance-and-Yield

All mutation methods (next, prev, left, right, parent) follow a look-before-you-leap sequence:

  1. They move the internal cursor pointer to the target destination node first.
  2. If the destination exists, they update the state and yield its data.
  3. If the edge points to an empty child or terminal bound, the internal state becomes None, and the method yields None.

⚠️ Crucial Warning: Because movement methods advance the cursor before reading, calling a movement method immediately after initialization will skip the data of the node you started on. Always check .get() first if you need to process the initial search node.

Implementations§

Source§

impl<'a, K, V, S> NavCursor<'a, K, V, S>

Source

pub fn get(&self) -> Option<(&'a K, &'a V, &'a S)>

Returns a reference to the current node’s key, value, and stats.

Source

pub fn peek_next(&self) -> Option<(&'a K, &'a V, &'a S)>

Returns a reference to the next node’s key, value, and stats without moving the cursor.

Source

pub fn peek_prev(&self) -> Option<(&'a K, &'a V, &'a S)>

Returns a reference to the previous node’s key, value, and stats without moving the cursor.

Source

pub fn peek_parent(&self) -> Option<(&'a K, &'a V, &'a S)>

Returns a reference to the parent node’s key, value, and stats without moving the cursor.

Source

pub fn peek_left(&self) -> Option<(&'a K, &'a V, &'a S)>

Returns a reference to the left child node’s key, value, and stats without moving the cursor.

Source

pub fn peek_right(&self) -> Option<(&'a K, &'a V, &'a S)>

Returns a reference to the right child node’s key, value, and stats without moving the cursor.

Source

pub fn next(&mut self) -> Option<(&'a K, &'a V, &'a S)>

Moves the cursor to the next node in sorted order and returns its key, value, and stats.

Source

pub fn prev(&mut self) -> Option<(&'a K, &'a V, &'a S)>

Moves the cursor to the previous node in sorted order and returns its key, value, and stats.

Source

pub fn parent(&mut self) -> Option<(&'a K, &'a V, &'a S)>

Moves the cursor to the parent node and returns its key, value, and stats.

Source

pub fn left(&mut self) -> Option<(&'a K, &'a V, &'a S)>

Moves the cursor to the left child node and returns its key, value, and stats.

Source

pub fn right(&mut self) -> Option<(&'a K, &'a V, &'a S)>

Moves the cursor to the right child node and returns its key, value, and stats.

Trait Implementations§

Source§

impl<K, V, S> Clone for NavCursor<'_, K, V, S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, K: Copy, V: Copy, S: Copy> Copy for NavCursor<'a, K, V, S>

Source§

impl<'a, K: Debug, V: Debug, S: Debug> Debug for NavCursor<'a, K, V, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, K, V, S> !Send for NavCursor<'a, K, V, S>

§

impl<'a, K, V, S> !Sync for NavCursor<'a, K, V, S>

§

impl<'a, K, V, S> Freeze for NavCursor<'a, K, V, S>

§

impl<'a, K, V, S> RefUnwindSafe for NavCursor<'a, K, V, S>

§

impl<'a, K, V, S> Unpin for NavCursor<'a, K, V, S>

§

impl<'a, K, V, S> UnsafeUnpin for NavCursor<'a, K, V, S>

§

impl<'a, K, V, S> UnwindSafe for NavCursor<'a, K, V, S>

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.