pub struct TreeNode<T> { /* private fields */ }Implementations§
Source§impl<T> TreeNode<T>
impl<T> TreeNode<T>
pub fn new(val: T) -> Self
pub fn with_arity(val: T, arity: Arity) -> Self
pub fn with_children<N>(val: T, children: Vec<N>) -> Self
pub fn is_leaf(&self) -> bool
pub fn add_child(&mut self, child: impl Into<TreeNode<T>>)
pub fn attach(self, other: impl Into<TreeNode<T>>) -> Self
pub fn children(&self) -> Option<&Vec<TreeNode<T>>>
pub fn children_mut(&mut self) -> Option<&mut Vec<TreeNode<T>>>
pub fn size(&self) -> usize
pub fn height(&self) -> usize
pub fn swap_subtrees( &mut self, other: &mut TreeNode<T>, self_idx: usize, other_idx: usize, )
pub fn get_mut(&mut self, index: usize) -> Option<&mut TreeNode<T>>
Trait Implementations§
Source§impl<T, V> Eval<[V], V> for TreeNode<T>
Implements the Reduce trait for TreeNode<T> where T is Eval<[V], V>. This is where the real work is done.
It recursively evaluates the TreeNode and its children until it reaches a leaf node,
at which point it applies the T’s eval fn to the input.
impl<T, V> Eval<[V], V> for TreeNode<T>
Implements the Reduce trait for TreeNode<T> where T is Eval<[V], V>. This is where the real work is done.
It recursively evaluates the TreeNode and its children until it reaches a leaf node,
at which point it applies the T’s eval fn to the input.
Because a Tree has only a single root node, this can only be used to return a single value.
We assume here that each leaf can eval the incoming input - this is a safe and the
only real logical assumption we can make.
Source§impl<T: Clone + Default> Factory<NodeType, TreeNode<T>> for NodeStore<T>
impl<T: Clone + Default> Factory<NodeType, TreeNode<T>> for NodeStore<T>
fn new_instance(&self, input: NodeType) -> TreeNode<T>
Source§impl<T> Gene for TreeNode<T>
impl<T> Gene for TreeNode<T>
type Allele = T
Source§fn allele(&self) -> &Self::Allele
fn allele(&self) -> &Self::Allele
Get the
allele of the Gene. This is the value that the Gene represents or “expresses”.Source§fn new_instance(&self) -> Self
fn new_instance(&self) -> Self
Create a new instance of the
Gene.Source§fn with_allele(&self, allele: &Self::Allele) -> Self
fn with_allele(&self, allele: &Self::Allele) -> Self
Create a new
Gene with the given allele.Source§impl<T> TreeIterator<T> for TreeNode<T>
Implement the TreeIterator trait for TreeNode
impl<T> TreeIterator<T> for TreeNode<T>
Implement the TreeIterator trait for TreeNode
This allows for traversal of a single node and its children in pre-order, post-order, and breadth-first order.
fn iter_pre_order(&self) -> PreOrderIterator<'_, T>
fn iter_post_order(&self) -> PostOrderIterator<'_, T>
fn iter_breadth_first(&self) -> TreeBreadthFirstIterator<'_, T>
impl<T> StructuralPartialEq for TreeNode<T>
Auto Trait Implementations§
impl<T> Freeze for TreeNode<T>where
T: Freeze,
impl<T> RefUnwindSafe for TreeNode<T>where
T: RefUnwindSafe,
impl<T> Send for TreeNode<T>where
T: Send,
impl<T> Sync for TreeNode<T>where
T: Sync,
impl<T> Unpin for TreeNode<T>where
T: Unpin,
impl<T> UnwindSafe for TreeNode<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