pub struct CursorMut<'a, T> { /* private fields */ }Expand description
A cursor over mutable Node data with safe, reference-counted Position handles.
This struct represents the majority of major operations for the GenTree structure.
All operations run in O(1) time unless otherwise noted.
Implementations§
Source§impl<'a, T> CursorMut<'a, T>
impl<'a, T> CursorMut<'a, T>
Sourcepub fn num_children(&self) -> usize
pub fn num_children(&self) -> usize
Returns the number of children for the Node under the cursor as usize
Sourcepub fn height(&self) -> usize
pub fn height(&self) -> usize
Returns the height of the tallest sub-tree for the current position ** The recursive guts of the height function */
Sourcepub fn get_data(&self) -> Option<Ref<'_, T>>
pub fn get_data(&self) -> Option<Ref<'_, T>>
Returns an immutable reference to the data under the cursor, if Some
Sourcepub fn get_for_pos(&'a self, pos: &'a Position<T>) -> Option<Ref<'a, T>>
pub fn get_for_pos(&'a self, pos: &'a Position<T>) -> Option<Ref<'a, T>>
Returns an immutable reference to the data for a supplied Position
Sourcepub fn add_child(&mut self, data: T)
pub fn add_child(&mut self, data: T)
Adds a new child Node under the current cursor and advances the cursor
to the new child
Sourcepub fn children(&self) -> Vec<Position<T>>
pub fn children(&self) -> Vec<Position<T>>
Returns a list of owned descendant (child) Positions for the Node
under the cursor in O(c) time where c is the number of children; The
clone used here is a cheap pointer copy, not an underlying data copy
Sourcepub fn delete(&mut self) -> Option<T>
pub fn delete(&mut self) -> Option<T>
Warning: Broken! Does not handle root deletion properly.
Removes the node at the current cursor position and returns its data,
if Some. Operation executes in O(c) time where c is the number of
children for the given node; Adds all children to the parent
(if Some), and returns the deleted Node; If the cursor is at the tree’s
root, this just deletes the Node’s data, leaving None; Moves the cursor
to the parent, if Some */