Struct CountNode

Source
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> Debug for CountNode<T>
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Node for CountNode<T>

Source§

type Value = T

Source§

fn left(&self) -> Option<&Self>

Get a reference to the left subtree
Source§

fn right(&self) -> Option<&Self>

Get a reference to the right subtree
Source§

fn value(&self) -> &T

Returns the value of the current node.
Source§

fn walk<'a, F>(&'a self, step_in: F)
where F: FnMut(&'a Self) -> WalkAction,

Walk down the tree
Source§

impl<T> NodeMut for CountNode<T>

Source§

type NodePtr = Box<CountNode<T>>

Source§

fn detach_left(&mut self) -> Option<Self::NodePtr>

Try to detach the left sub-tree
Source§

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>

Replace the left subtree with tree and return the old one.
Source§

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

Returns a mutable reference to the value of the current node.
Source§

fn into_parts(self) -> (T, Option<Self::NodePtr>, Option<Self::NodePtr>)

Consume a Node and return its parts: (value, left, right)
Source§

fn left_mut(&mut self) -> Option<&mut Self>

Returns a mutable reference to the left child
Source§

fn right_mut(&mut self) -> Option<&mut Self>

Returns a mutable reference to the right child
Source§

fn rotate_left(&mut self) -> Result<(), ()>

Try to rotate the tree left if right subtree exists
Source§

fn rotate_right(&mut self) -> Result<(), ()>

Try to rotate the tree right if left subtree exists
Source§

fn walk_mut<'a, FI, FS>(&'a mut self, step_in: FI, stop: FS)
where FI: FnMut(&Self) -> WalkAction, FS: FnOnce(&'a mut Self),

Simple mutable walk Read more
Source§

fn walk_reshape<FI, FS, FO>(&mut self, step_in: FI, stop: FS, step_out: FO)
where FI: FnMut(&mut Self) -> WalkAction, FS: FnOnce(&mut Self), FO: FnMut(&mut Self, WalkAction),

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),

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),

Extract out a node. This can be used in conjuction with try_remove to remove any node except the root. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.