[][src]Enum structures::tree::Tree

pub enum Tree<T> {
    Empty,
    Branch(T, Box<Self>, Box<Self>),
}

Binary Tree

Examples

use structures::tree::{TraverseOrder, Tree};

let tree = Tree::branch(1, Tree::leaf(2), Tree::leaf(3));

println!("{:#?}", tree);

println!("{:?}", tree.iter(TraverseOrder::InOrder).collect::<Vec<_>>());

Variants

EmptyBranch(T, Box<Self>, Box<Self>)

Methods

impl<T> Tree<T>[src]

pub fn empty() -> Self[src]

pub fn leaf(v: T) -> Self[src]

pub fn branch(v: T, l: Self, r: Self) -> Self[src]

pub fn left(&self) -> Option<&Self>[src]

pub fn right(&self) -> Option<&Self>[src]

pub fn value(&self) -> Option<&T>[src]

pub fn iter(&self, order: TraverseOrder) -> impl Iterator<Item = &T>[src]

pub fn traverse(&self, order: TraverseOrder, f: &mut dyn FnMut(&T))[src]

Trait Implementations

impl<T: PartialEq> PartialEq<Tree<T>> for Tree<T>[src]

impl<T: Debug> Debug for Tree<T>[src]

Auto Trait Implementations

impl<T> Send for Tree<T> where
    T: Send

impl<T> Sync for Tree<T> where
    T: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.