pub struct TreeNode<T: Copy> {
pub value: T,
pub left: Option<Box<TreeNode<T>>>,
pub right: Option<Box<TreeNode<T>>>,
}
Expand description
A node in a binary tree.
Can be used for many interesting algorithmic things.
Fields§
§value: T
§left: Option<Box<TreeNode<T>>>
The left node, may be None
.
right: Option<Box<TreeNode<T>>>
The right node, may be None
.
Implementations§
source§impl<T: Copy> TreeNode<T>
impl<T: Copy> TreeNode<T>
sourcepub fn reduce<R>(&self, reducer: fn(_: Option<R>, _: T, _: Option<R>) -> R) -> R
pub fn reduce<R>(&self, reducer: fn(_: Option<R>, _: T, _: Option<R>) -> R) -> R
Recursively reduces each element in tree.
sourcepub fn insert_left(&mut self, value: T)
pub fn insert_left(&mut self, value: T)
Recursively inserts to the left of node until there is one empty space.
sourcepub fn insert_right(&mut self, value: T)
pub fn insert_right(&mut self, value: T)
Recursively inserts to the right of node until there is one empty space.
Trait Implementations§
Auto Trait Implementations§
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