Struct Node

Source
pub struct Node<T> { /* private fields */ }
Expand description

Node<T> represents the single node in a tree.

Implementations§

Source§

impl<T: ItemType> Node<T>

Source

pub fn new(item: Option<T>, count: usize) -> Node<T>

Create a new Node with the given item and count.

Source

pub fn new_rc(item: Option<T>, count: usize) -> Rc<Node<T>>

Create a new Rc with the given item and count.

Source

pub fn add_child(self: &Rc<Self>, child_node: Rc<Node<T>>)

Add the given child Node as a child of this node.

Source

pub fn remove_child(self: &Rc<Self>, child_node: Rc<Node<T>>)

Source

pub fn search(&self, item: T) -> Option<Rc<Node<T>>>

Check whether this node contains a child node for the given item. If so, that node’s reference is returned; otherwise, None is returned.

Source

pub fn increment(&self, incr_count: usize)

Increment the count associated with this node’s item.

Source

pub fn print(&self, depth: usize)

Print out the node.

Source

pub fn item(&self) -> Option<T>

Source

pub fn count(&self) -> usize

Return the count value this node’s item holds.

Source

pub fn neighbor(&self) -> Option<Rc<Node<T>>>

Return this node’s neighbor node.

Source

pub fn parent(&self) -> Option<Rc<Node<T>>>

Return this node’s parent node.

Source

pub fn is_root(&self) -> bool

Check whether this node is a root node.

Source

pub fn is_leaf(&self) -> bool

Check whether this node is a leaf node.

Trait Implementations§

Source§

impl<T: Debug> Debug for Node<T>

Source§

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

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

impl<T: ItemType> PartialEq for Node<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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.

Auto Trait Implementations§

§

impl<T> !Freeze for Node<T>

§

impl<T> !RefUnwindSafe for Node<T>

§

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>

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