[][src]Struct radiate_matrix_tree::tree::node::Node

pub struct Node<T: Clone> { /* fields omitted */ }

a Node struct to represent a bidirectional binary tree holding pointers to the parent and two children, the left and right child

Implementations

impl<T: Clone> Node<T>[src]

implement the node

pub fn new(elem: T) -> Box<Self>[src]

create a new node.

pub fn get(&self) -> &T[src]

pub fn get_mut(&mut self) -> &mut T[src]

pub fn is(&self, node: &Node<T>) -> bool[src]

Check if node 'is' the same as this node. This just checks that the references are for the same 'Node'

pub fn check_left_child(&self, node: &Node<T>) -> bool[src]

return true if this node is the left child, false if not

pub fn check_right_child(&self, node: &Node<T>) -> bool[src]

return true if this node is the right child, false if not

pub fn is_left_child(&self) -> Option<bool>[src]

return true if this node is the left child of it's parent, false if not returns None if node doesn't have a parent.

pub fn is_leaf(&self) -> bool[src]

return true if this node is a leaf node, meaning it has no children.

pub fn has_left_child(&self) -> bool[src]

return true if this node has a valid left child and is not pointing to a null pointer

pub fn has_right_child(&self) -> bool[src]

return true if this node has a valid right child and is not pointing to a null pointer

pub fn has_parent(&self) -> bool[src]

return true if this node has a parent, false if not. If it does not, then this node is the root of the tree.

pub fn set_left_child(&mut self, child: Link<T>)[src]

Safely set the left child node. Will drop any old left child node.

pub fn set_right_child(&mut self, child: Link<T>)[src]

Safely set the right child node. Will drop any old right child node.

pub fn set_parent(&mut self, parent: *mut Node<T>)[src]

Safely set the node's parent. If the node already has a parent, this node will be removed from it.

pub fn left_child_mut_opt(&mut self) -> Option<&mut Node<T>>[src]

Safely returns a mutable reference to this node's left child.

pub fn right_child_mut_opt(&mut self) -> Option<&mut Node<T>>[src]

Safely returns a mutable reference to this node's right child.

pub fn parent_mut_opt(&mut self) -> Option<&mut Node<T>>[src]

Safely returns a mutable reference to this node's parent.

pub fn left_child_opt(&self) -> Option<&Node<T>>[src]

Safely returns a reference to this node's left child.

pub fn right_child_opt(&self) -> Option<&Node<T>>[src]

Safely returns a reference to this node's right child.

pub fn parent_opt(&self) -> Option<&Node<T>>[src]

Safely returns a reference to this node's parent.

pub fn take_left_child(&mut self) -> Link<T>[src]

Remove and return the left child node. The returned node is owned by the caller

pub fn take_right_child(&mut self) -> Link<T>[src]

Remove and return the right child node. The returned node is owned by the caller

pub fn remove_from_parent(&mut self)[src]

Safely detach this node from it's parent.

pub fn height(&self) -> i32[src]

return the height of this node recursivley

pub fn depth(&self) -> i32[src]

return the depth of this node, meaning the number of levels down it is from the root of the tree, recrsive.

pub fn size(&self) -> i32[src]

return the size of the subtree recrusivley.

pub fn copy(&self) -> Box<Node<T>>[src]

Return a thin copy of this node, meaning keep all information besides the family pointers, these are nulled-out in order to avoid dangling or circular references.

pub fn deepcopy(&self) -> Box<Node<T>>[src]

deep copy this node and it's subnodes. Recursivley traverse the tree in order and thin copy the current node, then assign it's surroudning pointers recrusivley.

pub fn insert_random(&mut self, node: Box<Node<T>>)[src]

Randomly insert a node into the tree.

pub fn display(&self, level: i32)[src]

Recrusively display the node and it's subnodes Useful for visualizing the strucutre of the tree and debugging. Level is the depth of the tree, at the root it should be 0.

Trait Implementations

impl<T: Clone> Debug for Node<T>[src]

implement debut for the node to give a little more information for the node and make it easier to trace through a tree when a tree is displayed

impl<T: Clone> Deref for Node<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: Clone> DerefMut for Node<T>[src]

impl<T: Clone> PartialEq<Node<T>> for Node<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Node<T> where
    T: RefUnwindSafe

impl<T> !Send for Node<T>

impl<T> !Sync for Node<T>

impl<T> Unpin for Node<T> where
    T: Unpin

impl<T> UnwindSafe for Node<T> where
    T: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,