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:
- They move the internal cursor pointer to the target destination node first.
- If the destination exists, they update the state and yield its data.
- If the edge points to an empty child or terminal bound, the internal state
becomes
None, and the method yieldsNone.
⚠️ 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§
Sourcepub fn get(&self) -> Option<(&'a K, &'a V, &'a S)>
pub fn get(&self) -> Option<(&'a K, &'a V, &'a S)>
Returns a reference to the current node’s key, value, and stats.
Sourcepub fn peek_next(&self) -> Option<(&'a K, &'a V, &'a S)>
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.
Sourcepub fn peek_prev(&self) -> Option<(&'a K, &'a V, &'a S)>
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.
Sourcepub fn peek_parent(&self) -> Option<(&'a K, &'a V, &'a S)>
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.
Sourcepub fn peek_left(&self) -> Option<(&'a K, &'a V, &'a S)>
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.
Sourcepub fn peek_right(&self) -> Option<(&'a K, &'a V, &'a S)>
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.
Sourcepub fn next(&mut self) -> Option<(&'a K, &'a V, &'a S)>
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.
Sourcepub fn prev(&mut self) -> Option<(&'a K, &'a V, &'a S)>
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.
Sourcepub fn parent(&mut self) -> Option<(&'a K, &'a V, &'a S)>
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.