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§
Sourcefn get_value_to_print(&self) -> String
fn get_value_to_print(&self) -> String
Get value string from current node
Provided Methods§
Sourcefn count_leaves(&self) -> u32
fn count_leaves(&self) -> u32
Return the leaves number of current node, which will be called by CommonTreeTrait.count_leaves
Sourcefn get_height(&self) -> u32
fn get_height(&self) -> u32
Return the height of current node, which will be called by CommonTreeTrait.height
Sourcefn in_order_traversal(&self)
fn in_order_traversal(&self)
Print nodes inorder, which will be called by CommonTreeTrait.in_order_traversal
fn in_order_traversal_for_test(&self, container: &mut Vec<T>)
Sourcefn pre_order_traversal(&self)
fn pre_order_traversal(&self)
Print nodes preorder, which will be called by CommonTreeTrait.pre_order_traversal
fn pre_order_traversal_for_test(&self, container: &mut Vec<T>)
Sourcefn contains(&self, value: T) -> bool
fn contains(&self, value: T) -> bool
Determine whether the node and its successors contains given value, which will be called by CommonTreeTrait.contains
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, )
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".