Skip to main content

TreeNode

Struct TreeNode 

Source
pub struct TreeNode<T: Ord + Copy + Debug + Display> {
    pub value: T,
    /* private fields */
}
Expand description

Node struct for AVLTree

Fields§

§value: T

Trait Implementations§

Source§

impl<T: Clone + Ord + Copy + Debug + Display> Clone for TreeNode<T>

Source§

fn clone(&self) -> TreeNode<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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

Source§

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

Get left child node
Source§

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

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
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, )

Source§

impl<T: Ord + Copy + Debug + Display> CommonTreeTrait<T, TreeNode<T>> for AVLTree<T>

Source§

fn get_root(&self) -> Option<Rc<RefCell<TreeNode<T>>>>

Source§

fn count_leaves(&self) -> u32

Counts leaves(None nodes) of the Tree Read more
Source§

fn height(&self) -> u32

Gets height of the Tree (from root to leaves) Read more
Source§

fn in_order_traversal(&self)

Prints Tree inorder Read more
Source§

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

Source§

fn pre_order_traversal(&self)

Prints red-black tree preorder Read more
Source§

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

Source§

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

Determine whether the tree contains given value Read more
Source§

fn is_tree_empty(&self) -> bool

Source§

fn min(&self) -> Option<T>

Source§

fn max(&self) -> Option<T>

Source§

fn print(&self)

Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Ord + Copy + Debug + Display> Drop for TreeNode<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: PartialEq + Ord + Copy + Debug + Display> PartialEq for TreeNode<T>

Source§

fn eq(&self, other: &TreeNode<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Ord + Copy + Debug + Display> StructuralPartialEq for TreeNode<T>

Auto Trait Implementations§

§

impl<T> Freeze for TreeNode<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for TreeNode<T>

§

impl<T> !Send for TreeNode<T>

§

impl<T> !Sync for TreeNode<T>

§

impl<T> Unpin for TreeNode<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TreeNode<T>
where T: UnsafeUnpin,

§

impl<T> !UnwindSafe for TreeNode<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.