[][src]Trait compt::Visitor

pub trait Visitor: Sized {
    type Item;
    pub fn next(self) -> (Self::Item, Option<[Self; 2]>);

    pub fn level_remaining_hint(&self) -> (usize, Option<usize>) { ... }
pub fn with_depth(self, start_depth: Depth) -> LevelIter<Self> { ... }
pub fn zip<F: Visitor>(self, f: F) -> Zip<Self, F> { ... }
pub fn map<B, F: Fn(Self::Item) -> B>(self, func: F) -> Map<Self, F> { ... }
pub fn take(self, num: usize) -> Take<Self> { ... }
pub fn flip(self) -> Flip<Self> { ... }
pub fn dfs_preorder_iter(self) -> DfsPreOrderIter<Self>

Notable traits for DfsPreOrderIter<C>

impl<C: Visitor> Iterator for DfsPreOrderIter<C> type Item = C::Item;
{ ... }
pub fn dfs_inorder_iter(self) -> DfsInOrderIter<Self>

Notable traits for DfsInOrderIter<C>

impl<C: Visitor> Iterator for DfsInOrderIter<C> type Item = C::Item;
{ ... }
pub fn dfs_preorder(self, func: impl FnMut(Self::Item)) { ... }
pub fn dfs_inorder(self, func: impl FnMut(Self::Item)) { ... }
pub fn dfs_postorder(self, func: impl FnMut(Self::Item)) { ... } }

The trait this crate revoles around. A complete binary tree visitor.

Associated Types

type Item

The common item produced for both leafs and non leafs.

Loading content...

Required methods

pub fn next(self) -> (Self::Item, Option<[Self; 2]>)

Consume this visitor, and produce the element it was pointing to along with it's children visitors.

Loading content...

Provided methods

pub fn level_remaining_hint(&self) -> (usize, Option<usize>)

Return the levels remaining including the one that will be produced by consuming this iterator. So if you first made this object from the root for a tree of size 5, it should return 5. Think of is as height-depth. This is used to make good allocations when doing dfs and bfs. Defaults to (0,None)

pub fn with_depth(self, start_depth: Depth) -> LevelIter<Self>

Iterator Adapter to also produce the depth each iteration.

pub fn zip<F: Visitor>(self, f: F) -> Zip<Self, F>

Combine two tree visitors.

pub fn map<B, F: Fn(Self::Item) -> B>(self, func: F) -> Map<Self, F>

Map iterator adapter

pub fn take(self, num: usize) -> Take<Self>

Only produce children up to num.

pub fn flip(self) -> Flip<Self>

Flips left and right children.

pub fn dfs_preorder_iter(self) -> DfsPreOrderIter<Self>

Notable traits for DfsPreOrderIter<C>

impl<C: Visitor> Iterator for DfsPreOrderIter<C> type Item = C::Item;

Provides a dfs preorder iterator. Unlike the callback version, This one relies on dynamic allocation for its stack.

pub fn dfs_inorder_iter(self) -> DfsInOrderIter<Self>

Notable traits for DfsInOrderIter<C>

impl<C: Visitor> Iterator for DfsInOrderIter<C> type Item = C::Item;

pub fn dfs_preorder(self, func: impl FnMut(Self::Item))

Calls the closure in dfs preorder (root,left,right). Takes advantage of the callstack to do dfs.

pub fn dfs_inorder(self, func: impl FnMut(Self::Item))

Calls the closure in dfs preorder (left,right,root). Takes advantage of the callstack to do dfs.

pub fn dfs_postorder(self, func: impl FnMut(Self::Item))

Calls the closure in dfs preorder (left,right,root). Takes advantage of the callstack to do dfs.

Loading content...

Implementors

impl<'a, T: 'a> Visitor for compt::bfs_order::Vistr<'a, T>[src]

type Item = &'a T

impl<'a, T: 'a> Visitor for compt::bfs_order::VistrMut<'a, T>[src]

type Item = &'a mut T

impl<'a, T: 'a> Visitor for compt::dfs_order::Vistr<'a, T, InOrder>[src]

type Item = &'a T

pub fn dfs_inorder(self, func: impl FnMut(Self::Item))[src]

Calls the closure in dfs preorder (root,left,right). Takes advantage of the callstack to do dfs.

impl<'a, T: 'a> Visitor for compt::dfs_order::Vistr<'a, T, PostOrder>[src]

type Item = &'a T

pub fn dfs_postorder(self, func: impl FnMut(Self::Item))[src]

Calls the closure in dfs preorder (root,left,right). Takes advantage of the callstack to do dfs.

impl<'a, T: 'a> Visitor for compt::dfs_order::Vistr<'a, T, PreOrder>[src]

type Item = &'a T

pub fn dfs_preorder(self, func: impl FnMut(Self::Item))[src]

Calls the closure in dfs preorder (root,left,right). Takes advantage of the callstack to do dfs.

impl<'a, T: 'a> Visitor for compt::dfs_order::VistrMut<'a, T, InOrder>[src]

type Item = &'a mut T

pub fn dfs_inorder(self, func: impl FnMut(Self::Item))[src]

Calls the closure in dfs preorder (root,left,right). Takes advantage of the callstack to do dfs.

impl<'a, T: 'a> Visitor for compt::dfs_order::VistrMut<'a, T, PostOrder>[src]

type Item = &'a mut T

pub fn dfs_postorder(self, func: impl FnMut(Self::Item))[src]

Calls the closure in dfs preorder (root,left,right). Takes advantage of the callstack to do dfs.

impl<'a, T: 'a> Visitor for compt::dfs_order::VistrMut<'a, T, PreOrder>[src]

type Item = &'a mut T

pub fn dfs_preorder(self, func: impl FnMut(Self::Item))[src]

Calls the closure in dfs preorder (root,left,right). Takes advantage of the callstack to do dfs.

impl<B, C: Visitor, F: Fn(C::Item) -> B + Clone> Visitor for Map<C, F>[src]

type Item = B

impl<T1: Visitor, T2: Visitor> Visitor for Zip<T1, T2>[src]

type Item = (T1::Item, T2::Item)

impl<T: Visitor> Visitor for Flip<T>[src]

type Item = T::Item

impl<T: Visitor> Visitor for LevelIter<T>[src]

type Item = (Depth, T::Item)

impl<T: Visitor> Visitor for Take<T>[src]

type Item = T::Item

Loading content...