Skip to main content

BinaryNode

Struct BinaryNode 

Source
pub struct BinaryNode<T> {
    pub data: T,
    /* private fields */
}
Expand description

二叉树节点结构体

Fields§

§data: T

Implementations§

Source§

impl<T> BinaryNode<T>
where T: Clone,

Source

pub fn new(data: T) -> Self

创建新的二叉树节点

§参数
  • data - 节点存储的数据
§返回值

返回新创建的二叉树节点

Source

pub fn left(&mut self, data: T) -> &Self

设置左子节点并返回不可变引用

§参数
  • data - 左子节点存储的数据
§返回值

当前节点的不可变引用

Source

pub fn right(&mut self, data: T) -> &Self

设置右子节点并返回不可变引用

§参数
  • data - 右子节点存储的数据
§返回值

当前节点的不可变引用

Source

pub fn left_mut(&mut self, data: T) -> &mut Self

设置左子节点并返回可变引用

§参数
  • data - 左子节点存储的数据
§返回值

当前节点的可变引用

Source

pub fn right_mut(&mut self, data: T) -> &mut Self

设置右子节点并返回可变引用

§参数
  • data - 右子节点存储的数据
§返回值

当前节点的可变引用

Source

pub fn node(&mut self) -> &mut Self

获取当前节点的可变引用

§返回值

当前节点的可变引用

Source

pub fn next_left_node(&mut self) -> Option<&mut Self>

获取下一个左节点的可变引用

§返回值

Option<BinaryNode> 如果存在,则返回该节点的引用,否则返回None

注意该函数不是创建节点,

Source

pub fn next_right_node(&mut self) -> Option<&mut BinaryNode<T>>

获取下一个右节点的可变引用

§返回值

Option<BinaryNode> 如果存在,则返回该节点的引用,否则返回None

注意该函数不是创建节点,

Source

pub fn get_data(&self) -> &T

获取节点数据的不可变引用

§返回值

节点数据的不可变引用

Source

pub fn mut_data(&mut self) -> &mut T

获取节点数据的可变引用

§返回值

节点数据的可变引用

Source

pub fn in_order_traverse_mut(&self) -> Vec<&T>

中序遍历二叉树(返回可变引用)

§返回值

包含所有节点数据可变引用的向量

Trait Implementations§

Source§

impl<T: Clone> Clone for BinaryNode<T>

Source§

fn clone(&self) -> BinaryNode<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: Debug> Debug for BinaryNode<T>

Source§

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

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

impl<T: Eq> Eq for BinaryNode<T>

Source§

impl<T: PartialEq> PartialEq for BinaryNode<T>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for BinaryNode<T>

Auto Trait Implementations§

§

impl<T> Freeze for BinaryNode<T>
where T: Freeze, Option<Box<BinaryNode<T>>>: Freeze,

§

impl<T> RefUnwindSafe for BinaryNode<T>

§

impl<T> Send for BinaryNode<T>
where T: Send, Option<Box<BinaryNode<T>>>: Send,

§

impl<T> Sync for BinaryNode<T>
where T: Sync, Option<Box<BinaryNode<T>>>: Sync,

§

impl<T> Unpin for BinaryNode<T>
where T: Unpin, Option<Box<BinaryNode<T>>>: Unpin,

§

impl<T> UnsafeUnpin for BinaryNode<T>

§

impl<T> UnwindSafe for BinaryNode<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.