Struct tree_iterators_rs::prelude::BinaryTreeNode
source · 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,
impl<'a, T> BorrowedBinaryTreeNode<'a> for BinaryTreeNode<T>where
Self: 'a,
§type BorrowedValue = &'a T
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])
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>>>)
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>
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>
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>
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>
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>
impl<T: Clone> Clone for BinaryTreeNode<T>
source§fn clone(&self) -> BinaryTreeNode<T>
fn clone(&self) -> BinaryTreeNode<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Debug> Debug for BinaryTreeNode<T>
impl<T: Debug> Debug for BinaryTreeNode<T>
source§impl<T: Default> Default for BinaryTreeNode<T>
impl<T: Default> Default for BinaryTreeNode<T>
source§fn default() -> BinaryTreeNode<T>
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,
impl<'a, T> MutBorrowedBinaryTreeNode<'a> for BinaryTreeNode<T>where
Self: 'a,
§type MutBorrowedValue = &'a mut T
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])
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>>>)
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>
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>
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>
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>
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>
impl<T> OwnedBinaryTreeNode for BinaryTreeNode<T>
§type OwnedValue = 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])
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>>>)
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>
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>
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>
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>
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> 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