pub enum TreeNode<T: Terminal, F: Function> {
Terminal(T),
Function(F, Vec<TreeNode<T, F>>),
}Expand description
A node in a GP tree
Variants§
Implementations§
Source§impl<T: Terminal, F: Function> TreeNode<T, F>
impl<T: Terminal, F: Function> TreeNode<T, F>
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Check if this is a terminal node
Sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Check if this is a function node
Sourcepub fn get_subtree(&self, path: &[usize]) -> Option<&Self>
pub fn get_subtree(&self, path: &[usize]) -> Option<&Self>
Get a subtree at the given path
Sourcepub fn get_subtree_mut(&mut self, path: &[usize]) -> Option<&mut Self>
pub fn get_subtree_mut(&mut self, path: &[usize]) -> Option<&mut Self>
Get a mutable subtree at the given path
Sourcepub fn replace_subtree(&mut self, path: &[usize], new_subtree: Self) -> bool
pub fn replace_subtree(&mut self, path: &[usize], new_subtree: Self) -> bool
Replace a subtree at the given path
Sourcepub fn terminal_positions(&self) -> Vec<Vec<usize>>
pub fn terminal_positions(&self) -> Vec<Vec<usize>>
Get all terminal positions
Sourcepub fn function_positions(&self) -> Vec<Vec<usize>>
pub fn function_positions(&self) -> Vec<Vec<usize>>
Get all function positions
Trait Implementations§
Source§impl<'de, T: Terminal, F: Function> Deserialize<'de> for TreeNode<T, F>
impl<'de, T: Terminal, F: Function> Deserialize<'de> for TreeNode<T, F>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: Terminal, F: Function> StructuralPartialEq for TreeNode<T, F>
Auto Trait Implementations§
impl<T, F> Freeze for TreeNode<T, F>
impl<T, F> RefUnwindSafe for TreeNode<T, F>where
T: RefUnwindSafe,
F: RefUnwindSafe,
impl<T, F> Send for TreeNode<T, F>
impl<T, F> Sync for TreeNode<T, F>
impl<T, F> Unpin for TreeNode<T, F>
impl<T, F> UnsafeUnpin for TreeNode<T, F>where
T: UnsafeUnpin,
F: UnsafeUnpin,
impl<T, F> UnwindSafe for TreeNode<T, F>where
T: UnwindSafe,
F: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.