Function walk_tree_prefix
fn walk_tree_prefix<S, B, I>(root: S, children_of: B) -> WalkTreePrefix<S, B>
where
S: Send,
B: Fn(&S) -> I + Send + Sync,
I: IntoIterator<Item = S>,
<I as >::IntoIter: DoubleEndedIterator
Create a tree-like prefix parallel iterator from an initial root node.
The children_of function should take a node and return an iterator over 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 prefix ordering. See also walk_tree_postfix,
which guarantees a postfix order.
If you don't care about ordering, you should use walk_tree,
which will use whatever is believed to be fastest.
For example a perfect binary tree of 7 nodes will reduced in the following order:
a
/ \
/ \
b c
/ \ / \
d e f g
reduced as a,b,d,e,c,f,g
Example
4
/ \
/ \
2 3
/ \
1 2
use walk_tree_prefix;
use *;
let par_iter = walk_tree_prefix;
assert_eq!;
Example
use *;
use walk_tree_prefix;
// Here we loop on the following tree:
//
// 10
// / \
// / \
// 3 14
// \
// \
// 18
let root = Node ;
let mut v: = walk_tree_prefix
.map
.collect;
assert_eq!;