pub struct Walk<'r, TP: TreeProperties, D = (), A = ()> { /* private fields */ }
Expand description
Walk tree
Some algorithms need to remember how they reached the current node via WalkedDirection
as D
.
When walking manually it might be useful to be able to store additional data via A
; look for functions with the suffix _with
.
Implementations§
source§impl<'r, TP: TreeProperties, D, A> Walk<'r, TP, D, A>
impl<'r, TP: TreeProperties, D, A> Walk<'r, TP, D, A>
source§impl<'r, TP: TreeProperties, D, A> Walk<'r, TP, D, A>where
D: From<WalkedDirection>,
impl<'r, TP: TreeProperties, D, A> Walk<'r, TP, D, A>where
D: From<WalkedDirection>,
sourcepub fn down_root_with(&mut self, add: A) -> bool
pub fn down_root_with(&mut self, add: A) -> bool
Walk down from tree to root node (if present)
sourcepub fn down_left_with(&mut self, add: A) -> bool
pub fn down_left_with(&mut self, add: A) -> bool
Walk down to left node if present and not currently at tree
sourcepub fn down_right_with(&mut self, add: A) -> bool
pub fn down_right_with(&mut self, add: A) -> bool
Walk down to right node if present and not currently at tree
source§impl<'r, TP: TreeProperties, D> Walk<'r, TP, D, ()>where
D: From<WalkedDirection>,
impl<'r, TP: TreeProperties, D> Walk<'r, TP, D, ()>where
D: From<WalkedDirection>,
sourcepub fn down_root(&mut self) -> bool
pub fn down_root(&mut self) -> bool
Walk down from tree to root node (if at tree and not empty)
sourcepub fn down_left(&mut self) -> bool
pub fn down_left(&mut self) -> bool
Walk down to left node if present and not currently at tree
sourcepub fn down_right(&mut self) -> bool
pub fn down_right(&mut self) -> bool
Walk down to right node if present and not currently at tree
source§impl<'r, TP: TreeProperties, D> Walk<'r, TP, D>where
D: From<WalkedDirection>,
impl<'r, TP: TreeProperties, D> Walk<'r, TP, D>where
D: From<WalkedDirection>,
sourcepub fn goto_insert(&mut self, key: &TP::Key) -> Option<InsertPosition>
pub fn goto_insert(&mut self, key: &TP::Key) -> Option<InsertPosition>
Walk to node where we’d have to insert key at
This can either be:
- root if and only if the tree is empty
- node with exactly matching key
- node where the key is between the parent node (possibly root) and the node
- to insert the key here we might have to create a new inner node and move the existing node down
source§impl<'r, TP: TreeProperties> Walk<'r, TP, WalkedDirection>
impl<'r, TP: TreeProperties> Walk<'r, TP, WalkedDirection>
sourcepub fn next_pre_order(&mut self) -> Option<&'r Node<TP>>
pub fn next_pre_order(&mut self) -> Option<&'r Node<TP>>
Tree traversal: depth-first pre-order
sourcepub fn next_in_order(&mut self) -> Option<&'r Node<TP>>
pub fn next_in_order(&mut self) -> Option<&'r Node<TP>>
Tree traversal: depth-first in-order
sourcepub fn next_leaf(&mut self) -> Option<&'r Node<TP>>
pub fn next_leaf(&mut self) -> Option<&'r Node<TP>>
Tree traversal: depth-first in-order leaf nodes only
sourcepub fn next_post_order(&mut self) -> Option<&'r Node<TP>>
pub fn next_post_order(&mut self) -> Option<&'r Node<TP>>
Tree traversal: depth-first post-order