pub struct BinaryTreeNode<T> {
    pub value: T,
    pub left: Option<Box<BinaryTreeNode<T>>>,
    pub right: Option<Box<BinaryTreeNode<T>>>,
}
Expand description

A default implemenation of a binary tree node. This struct provides a series of tree traversal utilities to allow you to easily work with and modify binary trees.

Fields§

§value: T

This node’s value

§left: Option<Box<BinaryTreeNode<T>>>

The left child of the current node.

§right: Option<Box<BinaryTreeNode<T>>>

The right child of the current node.

Trait Implementations§

source§

impl<'a, T> BorrowedBinaryTreeNode<'a> for BinaryTreeNode<T>
where Self: 'a,

§

type BorrowedValue = &'a T

A reference to the value of each node in the tree.
source§

fn get_value_and_children_binary_iter( &'a self ) -> (Self::BorrowedValue, [Option<&'a Self>; 2])

This method gets the value and left and right children from this node, borrowing it in the process. The other methods of this trait assume that the children do not contain any circular references. If they do, it will create an infinite loop.
source§

fn get_value_and_children_iter( &'a self ) -> (Self::BorrowedValue, Option<FlatMap<IntoIter<Option<&'a Self>, 2>, Option<&'a Self>, fn(_: Option<&'a Self>) -> Option<&'a Self>>>)

This method gets the value and children from this node, consuming it in the process. The other methods of this trait assume that the ‘Children’ list does not contain and circular references back to parent nodes.
source§

fn bfs_iter(&'a self) -> impl TreeIterator<Item = Self::BorrowedValue>

This method retrieves an iterator that can be used to perform Breadth First (Queue - specifically VecDeque-based) searches of a tree. Read more
source§

fn dfs_preorder_iter(&'a self) -> impl TreeIterator<Item = Self::BorrowedValue>

This method retrieves an iterator that can be used to perform Depth First Preorder searches of a tree. Read more
source§

fn dfs_inorder_iter(&'a self) -> impl TreeIterator<Item = Self::BorrowedValue>

This method retrieves an iterator that can be used to perform Depth First In Order searches of a tree. Read more
source§

fn dfs_postorder_iter(&'a self) -> impl TreeIterator<Item = Self::BorrowedValue>

This method retrieves an iterator that can be used to perform Depth First Postorder searches of a tree. Read more
source§

impl<T: Clone> Clone for BinaryTreeNode<T>

source§

fn clone(&self) -> BinaryTreeNode<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for BinaryTreeNode<T>

source§

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

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

impl<T: Default> Default for BinaryTreeNode<T>

source§

fn default() -> BinaryTreeNode<T>

Returns the “default value” for a type. Read more
source§

impl<'a, T> MutBorrowedBinaryTreeNode<'a> for BinaryTreeNode<T>
where Self: 'a,

§

type MutBorrowedValue = &'a mut T

A mutable reference to the value of each node in the tree.
source§

fn get_value_and_children_binary_iter_mut( &'a mut self ) -> (Self::MutBorrowedValue, [Option<&'a mut Self>; 2])

This method gets the value and left and right children from this node, borrowing it as mutable in the process. The other methods of this trait assume that the children do not contain any circular references. If they do, it will create an infinite loop.
source§

fn get_value_and_children_iter_mut( &'a mut self ) -> (Self::MutBorrowedValue, Option<FlatMap<IntoIter<Option<&'a mut Self>, 2>, Option<&'a mut Self>, fn(_: Option<&'a mut Self>) -> Option<&'a mut Self>>>)

This method gets the value and children from this node. The other methods of this trait assume that the ‘Children’ list does not contain any circular references. If there are, an infinite loop will result.
source§

fn bfs_iter_mut( &'a mut self ) -> impl TreeIteratorMut<Item = Self::MutBorrowedValue>

This method retrieves an iterator that can be used to perform Breadth First (Queue - specifically VecDeque-based) searches of a tree. Read more
source§

fn dfs_preorder_iter_mut( &'a mut self ) -> impl TreeIteratorMut<Item = Self::MutBorrowedValue>

This method retrieves an iterator that can be used to perform Depth First Preorder searches of a tree. Read more
source§

fn dfs_inorder_iter_mut( &'a mut self ) -> impl TreeIteratorMut<Item = Self::MutBorrowedValue>

This method retrieves an iterator that can be used to perform Depth First In Order searches of a tree. Read more
source§

fn dfs_postorder_iter_mut( &'a mut self ) -> impl TreeIteratorMut<Item = Self::MutBorrowedValue>

This method retrieves an iterator that can be used to perform Depth First Postorder searches of a tree. Read more
source§

impl<T> OwnedBinaryTreeNode for BinaryTreeNode<T>

§

type OwnedValue = T

The value of each node in the tree.
source§

fn get_value_and_children_binary(self) -> (Self::OwnedValue, [Option<Self>; 2])

This method gets the value and left and right children from this node, consuming it in the process. The other methods of this trait assume that the children do not contain any circular references. If they do, it will create an infinite loop.
source§

fn get_value_and_children( self ) -> (Self::OwnedValue, Option<FlatMap<IntoIter<Option<Self>, 2>, Option<Self>, fn(_: Option<Self>) -> Option<Self>>>)

This method gets the value and children from this node, consuming it in the process. The other methods of this trait assume that the ‘Children’ list does not contain any circular references. If it does, it will create an infinite loop.
source§

fn bfs(self) -> impl TreeIteratorMut<Item = Self::OwnedValue>

This method retrieves an iterator that can be used to perform Breadth First (Queue - specifically VecDeque-based) searches of a tree. Read more
source§

fn dfs_preorder(self) -> impl TreeIteratorMut<Item = Self::OwnedValue>

This method retrieves an iterator that can be used to perform Depth First Preorder searches of a tree. Read more
source§

fn dfs_inorder(self) -> impl TreeIteratorMut<Item = Self::OwnedValue>

This method retrieves an iterator that can be used to perform Depth First In Order searches of a tree. Read more
source§

fn dfs_postorder(self) -> impl TreeIteratorMut<Item = Self::OwnedValue>

This method retrieves an iterator that can be used to perform Depth First Postorder searches of a tree. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for BinaryTreeNode<T>
where T: RefUnwindSafe,

§

impl<T> Send for BinaryTreeNode<T>
where T: Send,

§

impl<T> Sync for BinaryTreeNode<T>
where T: Sync,

§

impl<T> Unpin for BinaryTreeNode<T>
where T: Unpin,

§

impl<T> UnwindSafe for BinaryTreeNode<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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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.