Struct tree_iterators_rs::prelude::TreeNode
source · pub struct TreeNode<T> {
pub value: T,
pub children: Option<Vec<TreeNode<T>>>,
}
Expand description
A default implemenation of a tree node. This struct provides a series of tree traversal utilities to allow you to easily work with and modify arbitrary trees.
Fields§
§value: T
This node’s value
children: Option<Vec<TreeNode<T>>>
The children of the current node.
Trait Implementations§
source§impl<'a, T> BorrowedTreeNode<'a> for TreeNode<T>where
T: 'a,
impl<'a, T> BorrowedTreeNode<'a> for TreeNode<T>where
T: 'a,
source§fn get_value_and_children_iter(
&'a self
) -> (Self::BorrowedValue, Option<Self::BorrowedChildren>)
fn get_value_and_children_iter( &'a self ) -> (Self::BorrowedValue, Option<Self::BorrowedChildren>)
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.
§type BorrowedValue = &'a T
type BorrowedValue = &'a T
§type BorrowedChildren = Iter<'a, TreeNode<T>>
type BorrowedChildren = Iter<'a, TreeNode<T>>
source§fn bfs_iter(&'a self) -> impl TreeIterator<Item = Self::BorrowedValue>
fn bfs_iter(&'a self) -> impl TreeIterator<Item = Self::BorrowedValue>
source§fn dfs_preorder_iter(&'a self) -> impl TreeIterator<Item = Self::BorrowedValue>
fn dfs_preorder_iter(&'a self) -> impl TreeIterator<Item = Self::BorrowedValue>
source§fn dfs_postorder_iter(&'a self) -> impl TreeIterator<Item = Self::BorrowedValue>
fn dfs_postorder_iter(&'a self) -> impl TreeIterator<Item = Self::BorrowedValue>
source§impl<'a, T> MutBorrowedTreeNode<'a> for TreeNode<T>where
T: 'a,
impl<'a, T> MutBorrowedTreeNode<'a> for TreeNode<T>where
T: 'a,
source§fn get_value_and_children_iter_mut(
&'a mut self
) -> (Self::MutBorrowedValue, Option<Self::MutBorrowedChildren>)
fn get_value_and_children_iter_mut( &'a mut self ) -> (Self::MutBorrowedValue, Option<Self::MutBorrowedChildren>)
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.
§type MutBorrowedValue = &'a mut T
type MutBorrowedValue = &'a mut T
§type MutBorrowedChildren = IterMut<'a, TreeNode<T>>
type MutBorrowedChildren = IterMut<'a, TreeNode<T>>
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>
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>
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>
source§impl<T> OwnedTreeNode for TreeNode<T>
impl<T> OwnedTreeNode for TreeNode<T>
source§fn get_value_and_children(
self
) -> (Self::OwnedValue, Option<Self::OwnedChildren>)
fn get_value_and_children( self ) -> (Self::OwnedValue, Option<Self::OwnedChildren>)
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.