Struct woodland::binary_tree::BinaryTreeNode[][src]

pub struct BinaryTreeNode<T> { /* fields omitted */ }
Expand description

The most simple node type in woodland. Stores a data field, a NodeId, as well as a left and right child.

All get’s and set’s are implemented via the NodeOperations and BinaryNodeOperations traits.

Notice that there is no way to create a BinaryTreeNode explicitly, as all nodes must be created by the corresponding tree’s memory arena. To learn more about memory arena’s and the implementation of tree’s in woodland, refer to the documentation home page.

Trait Implementations

impl<T> BinaryNodeOperations for BinaryTreeNode<T>[src]

fn get_left(&self) -> Option<NodeId>[src]

Get the left node

fn get_right(&self) -> Option<NodeId>[src]

Get the right node

fn set_left(&mut self, left_node_id: Option<NodeId>)[src]

Set the left node to a node by it’s NodeId

fn set_right(&mut self, right_node_id: Option<NodeId>)[src]

Set the right node to a node by it’s NodeId

impl<T: Debug> Debug for BinaryTreeNode<T>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<T: Hash> Hash for BinaryTreeNode<T>[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<'a, T> IterativeTreeOperations<BinaryTreeNode<T>> for BinaryTree<T> where
    T: Hash,
    T: Eq,
    T: PartialEq
[src]

fn preorder_iter(&self) -> Box<dyn Iterator<Item = &BinaryTreeNode<T>>>[src]

Get a preorder traveral iterator.

fn inorder_iter(&self) -> Box<dyn Iterator<Item = &BinaryTreeNode<T>>>[src]

Get an inorder traversal iterator.

fn postorder_iter(&self) -> Box<dyn Iterator<Item = &BinaryTreeNode<T>>>[src]

Get a postorder traversal iterator.

impl<T> NodeOperations for BinaryTreeNode<T>[src]

type T = T

fn new(data: T, id: NodeId) -> Self[src]

Create a new instance of the node with a given NodeId

fn get_id(&self) -> NodeId[src]

Get a reference to the id of the node

fn get_data(&self) -> &T[src]

Get a reference to the data inside the node

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

Get a mutable reference to the data inside the node

impl<T: PartialEq> PartialEq<BinaryTreeNode<T>> for BinaryTreeNode<T>[src]

fn eq(&self, other: &BinaryTreeNode<T>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &BinaryTreeNode<T>) -> bool[src]

This method tests for !=.

impl<T> TreeOperations<BinaryTreeNode<T>> for BinaryTree<T> where
    T: Hash,
    T: Eq,
    T: PartialEq
[src]

fn new() -> Self[src]

Create a new instance of the tree with an empty root.

fn create_node(&mut self, data: T) -> NodeId[src]

Genereate a new mutable reference to a NodeType. You must call this function to get new references since we are allocating all references in the Arena. Read more

fn count(&self) -> usize[src]

Get the number of nodes in the tree.

fn is_empty(&self) -> bool[src]

Returns true if there are no nodes in the tree, and returns false otherwise.

fn get_node(&self, node_id: NodeId) -> Option<&BinaryTreeNode<T>>[src]

Get a refrence to a NodeType<T> from a given NodeId, if a node with the specified NodeId exists in the tree. Read more

fn get_node_mut(&mut self, node_id: NodeId) -> Option<&mut BinaryTreeNode<T>>[src]

Get a mutable reference to a NodeType<T> from a given NodeId, if a node with the specified NodeId exists in the tree. Read more

fn search(&self, node_id: NodeId) -> bool[src]

Search to see if a node is inside the tree.

fn insert(&mut self, _node: NodeId)[src]

Insert a node into the tree.

impl<T: Eq> Eq for BinaryTreeNode<T>[src]

impl<T> StructuralEq for BinaryTreeNode<T>[src]

impl<T> StructuralPartialEq for BinaryTreeNode<T>[src]

Auto Trait Implementations

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

impl<T> Send for BinaryTreeNode<T> where
    T: Send

impl<T> Sync for BinaryTreeNode<T> where
    T: Sync

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

impl<T> UnwindSafe for BinaryTreeNode<T> where
    T: UnwindSafe

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

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

Immutably borrows from an owned value. Read more

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

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

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.