Skip to main content

CommonTreeNodeTrait

Trait CommonTreeNodeTrait 

Source
pub trait CommonTreeNodeTrait<T: Ord + Copy + Debug + Display> {
Show 15 methods // Required methods fn get_left(&self) -> Option<Rc<RefCell<Self>>>; fn get_right(&self) -> Option<Rc<RefCell<Self>>>; fn get_value(&self) -> T; fn get_value_to_print(&self) -> String; // Provided methods fn count_leaves(&self) -> u32 { ... } fn get_height(&self) -> u32 { ... } fn in_order_traversal(&self) { ... } fn in_order_traversal_for_test(&self, container: &mut Vec<T>) { ... } fn pre_order_traversal(&self) { ... } fn pre_order_traversal_for_test(&self, container: &mut Vec<T>) { ... } fn contains(&self, value: T) -> bool { ... } fn get_min_value_in_children(&self) -> T { ... } fn get_max_value_in_children(&self) -> T { ... } fn print(&self) { ... } fn print_helper( &self, row_index: usize, column_index: usize, container: &mut [&mut [String]], height: usize, ) { ... }
}
Expand description

Provide common functions for nodes

Required Methods§

Source

fn get_left(&self) -> Option<Rc<RefCell<Self>>>

Get left child node

Source

fn get_right(&self) -> Option<Rc<RefCell<Self>>>

Get right child node

Source

fn get_value(&self) -> T

Get value from current node

Source

fn get_value_to_print(&self) -> String

Get value string from current node

Provided Methods§

Source

fn count_leaves(&self) -> u32

Return the leaves number of current node, which will be called by CommonTreeTrait.count_leaves

Source

fn get_height(&self) -> u32

Return the height of current node, which will be called by CommonTreeTrait.height

Source

fn in_order_traversal(&self)

Print nodes inorder, which will be called by CommonTreeTrait.in_order_traversal

Source

fn in_order_traversal_for_test(&self, container: &mut Vec<T>)

Source

fn pre_order_traversal(&self)

Print nodes preorder, which will be called by CommonTreeTrait.pre_order_traversal

Source

fn pre_order_traversal_for_test(&self, container: &mut Vec<T>)

Source

fn contains(&self, value: T) -> bool

Determine whether the node and its successors contains given value, which will be called by CommonTreeTrait.contains

Source

fn get_min_value_in_children(&self) -> T

Source

fn get_max_value_in_children(&self) -> T

Source

fn print(&self)

Source

fn print_helper( &self, row_index: usize, column_index: usize, container: &mut [&mut [String]], height: usize, )

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Ord + Copy + Debug + Display> CommonTreeNodeTrait<T> for tree_collections::avlTree::TreeNode<T>

Source§

impl<T: Ord + Copy + Debug + Display> CommonTreeNodeTrait<T> for tree_collections::bsTree::TreeNode<T>

Source§

impl<T: Ord + Copy + Debug + Display> CommonTreeNodeTrait<T> for tree_collections::rbTree::TreeNode<T>

Source§

impl<T: Ord + Copy + Debug + Display> CommonTreeNodeTrait<T> for tree_collections::rbTreeFast::TreeNode<T>