pub struct CountNode<T> { /* private fields */ }
Expand description
Node of a CountTree
.
The only way of getting your hands on a CountNode
is through
CountTree::root()
method which
returns a shared reference to its root. Thus NodeMut
methods are not
accessible to users.
Trait Implementations§
Source§impl<T> Node for CountNode<T>
impl<T> Node for CountNode<T>
Source§impl<T> NodeMut for CountNode<T>
impl<T> NodeMut for CountNode<T>
type NodePtr = Box<CountNode<T>>
Source§fn detach_left(&mut self) -> Option<Self::NodePtr>
fn detach_left(&mut self) -> Option<Self::NodePtr>
Try to detach the left sub-tree
Source§fn detach_right(&mut self) -> Option<Self::NodePtr>
fn detach_right(&mut self) -> Option<Self::NodePtr>
Try to detach the right sub-tree
Source§fn insert_left(&mut self, tree: Option<Self::NodePtr>) -> Option<Self::NodePtr>
fn insert_left(&mut self, tree: Option<Self::NodePtr>) -> Option<Self::NodePtr>
Replace the left subtree with
tree
and return the old one.Source§fn insert_right(&mut self, tree: Option<Self::NodePtr>) -> Option<Self::NodePtr>
fn insert_right(&mut self, tree: Option<Self::NodePtr>) -> Option<Self::NodePtr>
Replace the right subtree with
tree
and return the old one.Source§fn value_mut(&mut self) -> &mut T
fn value_mut(&mut self) -> &mut T
Returns a mutable reference to the value of the current node.
Source§fn into_parts(self) -> (T, Option<Self::NodePtr>, Option<Self::NodePtr>)
fn into_parts(self) -> (T, Option<Self::NodePtr>, Option<Self::NodePtr>)
Consume a Node and return its parts: (value, left, right)
Source§fn rotate_left(&mut self) -> Result<(), ()>
fn rotate_left(&mut self) -> Result<(), ()>
Try to rotate the tree left if right subtree exists
Source§fn rotate_right(&mut self) -> Result<(), ()>
fn rotate_right(&mut self) -> Result<(), ()>
Try to rotate the tree right if left subtree exists
Source§fn walk_reshape<FI, FS, FO>(&mut self, step_in: FI, stop: FS, step_out: FO)
fn walk_reshape<FI, FS, FO>(&mut self, step_in: FI, stop: FS, step_out: FO)
Walks down the tree by detaching subtrees, then up reattaching them
back.
step_in
should guide the path taken, stop
will be called on
the node where either step_in
returned Stop
or it was not possible
to proceed. Then step_out
will be called for each node along the way
to root, except the final one (that for which stop
was called).Source§fn insert_before<F>(&mut self, new_node: Self::NodePtr, step_out: F)where
F: FnMut(&mut Self, WalkAction),
fn insert_before<F>(&mut self, new_node: Self::NodePtr, step_out: F)where
F: FnMut(&mut Self, WalkAction),
Insert
new_node
in-order before self
. step_out
will be invoked for
all nodes in path from (excluding) the point of insertion, to
(including) self
, unless self
is the point of insertion.Source§fn walk_extract<FI, FE, FO>(
&mut self,
step_in: FI,
extract: FE,
step_out: FO,
) -> Option<Self::NodePtr>where
FI: FnMut(&mut Self) -> WalkAction,
FE: FnOnce(&mut Self, &mut Option<Self::NodePtr>),
FO: FnMut(&mut Self, WalkAction),
fn walk_extract<FI, FE, FO>(
&mut self,
step_in: FI,
extract: FE,
step_out: FO,
) -> Option<Self::NodePtr>where
FI: FnMut(&mut Self) -> WalkAction,
FE: FnOnce(&mut Self, &mut Option<Self::NodePtr>),
FO: FnMut(&mut Self, WalkAction),
Extract out a node. This can be used in conjuction with
try_remove
to
remove any node except the root. Read moreSource§fn try_remove<F>(&mut self, step_out: F) -> Option<Self::NodePtr>where
F: FnMut(&mut Self, WalkAction),
fn try_remove<F>(&mut self, step_out: F) -> Option<Self::NodePtr>where
F: FnMut(&mut Self, WalkAction),
Replace this node with one of its descendant, returns
None
if it has
no children.Auto Trait Implementations§
impl<T> Freeze for CountNode<T>where
T: Freeze,
impl<T> RefUnwindSafe for CountNode<T>where
T: RefUnwindSafe,
impl<T> Send for CountNode<T>where
T: Send,
impl<T> Sync for CountNode<T>where
T: Sync,
impl<T> Unpin for CountNode<T>where
T: Unpin,
impl<T> UnwindSafe for CountNode<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more