[−][src]Function sharpen::tree_rollup::rollup_tree_bottomup
pub fn rollup_tree_bottomup<T, I, M>(
input: I,
mapping: M
) -> Option<impl Iterator<Item = T>> where
T: Node,
I: IntoIterator<Item = T>,
M: IntoIterator<Item = (usize, usize)>,
Roll up a tree given as a flat structure and a mapping {from child to parent} into a hierarchical structure.
Invariants for the arguments:
- Any parent must come after it's children inside
input
. - The largest index in
mapping
should be inside of the bounds ofinput
. mapping
keys (child) must be smaller than the associated value (parent)mapping
keys should be sorted
Return value:
- None: Detected duplicated usage of id's (probably the
mapping
was invalid). - Some(iter): The rolled-up tree, with only top-level children left at top-level.