pub trait Visitor: Sized {
type Item;
// Required method
fn next(self) -> (Self::Item, Option<[Self; 2]>);
// Provided methods
fn level_remaining_hint(&self) -> (usize, Option<usize>) { ... }
fn with_depth(self, start_depth: Depth) -> LevelIter<Self> { ... }
fn zip<F: Visitor>(self, f: F) -> Zip<Self, F> { ... }
fn map<B, F: Fn(Self::Item) -> B>(self, func: F) -> Map<Self, F> { ... }
fn take(self, num: usize) -> Take<Self> { ... }
fn flip(self) -> Flip<Self> { ... }
fn dfs_preorder_iter(self) -> DfsPreOrderIter<Self> ⓘ { ... }
fn dfs_inorder_iter(self) -> DfsInOrderIter<Self> ⓘ { ... }
fn dfs_preorder(self, func: impl FnMut(Self::Item)) { ... }
fn dfs_inorder(self, func: impl FnMut(Self::Item)) { ... }
fn dfs_postorder(self, func: impl FnMut(Self::Item)) { ... }
}Expand description
The trait this crate revoles around. A complete binary tree visitor.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn level_remaining_hint(&self) -> (usize, Option<usize>)
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)
Sourcefn with_depth(self, start_depth: Depth) -> LevelIter<Self>
fn with_depth(self, start_depth: Depth) -> LevelIter<Self>
Iterator Adapter to also produce the depth each iteration.
Sourcefn dfs_preorder_iter(self) -> DfsPreOrderIter<Self> ⓘ
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.
fn dfs_inorder_iter(self) -> DfsInOrderIter<Self> ⓘ
Sourcefn dfs_preorder(self, func: impl FnMut(Self::Item))
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.
Sourcefn dfs_inorder(self, func: impl FnMut(Self::Item))
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.
Sourcefn dfs_postorder(self, func: impl FnMut(Self::Item))
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.