Commit 991f5abd authored by Quentin Khan's avatar Quentin Khan
Browse files

FNode: add method to grow tree to given height

The split_to_height method splits all nodes in the tree until the given
height.
parent fb2995b0
......@@ -566,6 +566,20 @@ public:
}
}
void split_to_height(std::size_t new_height) {
bool done = false;
while(! done) {
done = true;
for(auto leaf : getTree().leaves()) {
if(leaf->getDepth() < new_height) {
leaf->split();
done = false;
break;
}
}
}
}
/** Applies a function to the node and it descendants in order */
void for_each_in_order(std::function<void(FNode*)> lambda) {
std::size_t idx = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment