Skip to main content

write_tree_iterative

Function write_tree_iterative 

Source
pub fn write_tree_iterative<W: Write>(
    out: &mut W,
    tree: &BTreeMap<String, Box<Tree>>,
    initial_depth: usize,
) -> Result<()>
Expand description

Writes the tree with indentation based on depth (ITERATIVE VERSION)

An explicit stack of iterators, one per open level, replaces the call stack: the same pre-order as write_tree, but the depth of the tree costs heap, not call stack.

ยงArguments

  • out - Where the lines go
  • tree - The tree to write
  • initial_depth - Depth level of the first line for indentation