[−][src]Trait compt::Visitor
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.
Required methods
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.
Provided methods
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)
fn with_depth(self, start_depth: Depth) -> LevelIter<Self>
Iterator Adapter to also produce the depth each iteration.
fn zip<F: Visitor>(self, f: F) -> Zip<Self, F>
Combine two tree visitors.
fn map<B, F: Fn(Self::Item) -> B>(self, func: F) -> Map<Self, F>
Map iterator adapter
fn take(self, num: usize) -> Take<Self>
Only produce children up to num.
fn flip(self) -> Flip<Self>
Flips left and right children.
ⓘImportant traits for DfsPreOrderIter<C>fn dfs_preorder_iter(self) -> DfsPreOrderIter<Self>
Provides a dfs preorder iterator. Unlike the callback version, This one relies on dynamic allocation for its stack.
ⓘImportant traits for DfsInOrderIter<C>fn dfs_inorder_iter(self) -> DfsInOrderIter<Self>
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.
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.
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.
Implementors
impl<'a, T: 'a> Visitor for compt::bfs_order::Vistr<'a, T>
[src]
type Item = &'a T
fn next(self) -> (Self::Item, Option<[Self; 2]>)
[src]
fn level_remaining_hint(&self) -> (usize, Option<usize>)
[src]
impl<'a, T: 'a> Visitor for compt::bfs_order::VistrMut<'a, T>
[src]
type Item = &'a mut T
fn next(self) -> (Self::Item, Option<[Self; 2]>)
[src]
fn level_remaining_hint(&self) -> (usize, Option<usize>)
[src]
impl<'a, T: 'a> Visitor for compt::dfs_order::Vistr<'a, T, InOrder>
[src]
type Item = &'a T
fn next(self) -> (Self::Item, Option<[Self; 2]>)
[src]
fn level_remaining_hint(&self) -> (usize, Option<usize>)
[src]
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
fn next(self) -> (Self::Item, Option<[Self; 2]>)
[src]
fn level_remaining_hint(&self) -> (usize, Option<usize>)
[src]
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
fn next(self) -> (Self::Item, Option<[Self; 2]>)
[src]
fn level_remaining_hint(&self) -> (usize, Option<usize>)
[src]
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
fn next(self) -> (Self::Item, Option<[Self; 2]>)
[src]
fn level_remaining_hint(&self) -> (usize, Option<usize>)
[src]
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
fn next(self) -> (Self::Item, Option<[Self; 2]>)
[src]
fn level_remaining_hint(&self) -> (usize, Option<usize>)
[src]
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
fn next(self) -> (Self::Item, Option<[Self; 2]>)
[src]
fn level_remaining_hint(&self) -> (usize, Option<usize>)
[src]
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.