Function walk_tree_postfix
fn walk_tree_postfix<S, B, I>(root: S, children_of: B) -> WalkTreePostfix<S, B>
where
S: Send,
B: Fn(&S) -> I + Send + Sync,
I: IntoIterator<Item = S>
Create a tree like postfix parallel iterator from an initial root node.
The children_of function should take a node and iterate on all of its child nodes.
The best parallelization is obtained when the tree is balanced
but we should also be able to handle harder cases.
Ordering
This function guarantees a postfix ordering. See also walk_tree_prefix which guarantees a
prefix order. If you don't care about ordering, you should use walk_tree, which will use
whatever is believed to be fastest.
Between siblings, children are reduced in order -- that is first children are reduced first.
For example a perfect binary tree of 7 nodes will reduced in the following order:
a
/ \
/ \
b c
/ \ / \
d e f g
reduced as d,e,b,f,g,c,a
Example
4
/ \
/ \
2 3
/ \
1 2
use walk_tree_postfix;
use *;
let par_iter = walk_tree_postfix;
assert_eq!;
Example
use *;
use walk_tree_postfix;
// Here we loop on the following tree:
//
// 10
// / \
// / \
// 3 14
// \
// \
// 18
let root = Node ;
let mut v: = walk_tree_postfix
.map
.collect;
assert_eq!;