pub struct AANode<T>(_);
Implementations
sourceimpl<T: Ord> AANode<T>
impl<T: Ord> AANode<T>
sourcepub fn insert(&mut self, content: T) -> bool
pub fn insert(&mut self, content: T) -> bool
Insert a new node with content
into the tree. If a node with this value already exist,
nothing will be inserted, and false
will be returned.
sourcepub fn insert_or_replace(&mut self, content: T) -> Option<T>
pub fn insert_or_replace(&mut self, content: T) -> Option<T>
Insert a new node with content
into the tree. If a node with this value already exists,
it will be replaced and the old content returned.
sourceimpl<T> AANode<T>
impl<T> AANode<T>
sourcepub fn traverse<'a, F, G, R>(
&'a self,
down_callback: F,
up_callback: G
) -> Option<R>where
F: Fn(&'a T) -> TraverseStep<R> + Copy,
G: Fn(&'a T, Option<R>) -> Option<R> + Copy,
pub fn traverse<'a, F, G, R>(
&'a self,
down_callback: F,
up_callback: G
) -> Option<R>where
F: Fn(&'a T) -> TraverseStep<R> + Copy,
G: Fn(&'a T, Option<R>) -> Option<R> + Copy,
Traverse the tree looking for a specific value.
down_callback
is called for each node on the way down the tree. It is passed the
value contained in the current node and may return either Left
or Right
to
continue the traversal in that direction, or Value
to stop the traversal, for
example because a value was found.
up_callback
is called while going back up with the content of each node and the
result of traversing so far (i.e., None
for the first call when the search hit a
leaf, or the return value of the last callback execution otherwise).
sourceimpl<T> AANode<T>
impl<T> AANode<T>
sourcepub fn has_left_child(&self) -> bool
pub fn has_left_child(&self) -> bool
Return true if this node has a left child.
sourcepub fn has_right_child(&self) -> bool
pub fn has_right_child(&self) -> bool
Return true if this node has a right child.