Crate bonsai

Source
Expand description

Implements various index arithmetic functions for perfect binary trees.

Functions§

children
Returns an index’s children.
expand
Returns an index’s family.
first_leaf
Returns the first leaf of a tree rooted at root with a depth.
general_index_to_subtree
Translate the general index index into a subtree index rooted at root.
is_in_subtree
Returns if index is in the subtree rooted at root.
last_leaf
Returns the last leaf of a tree rooted at root with a depth.
last_power_of_two
Returns the last power of two for n using bit twiddling.
log2
Returns the log base 2 of n.
next_power_of_two
Returns the next power of two for n using bit twiddling.
relative_depth
Returns the depth between two general indicies.
root_from_depth
Returns the subtree root for index assuming the tree is depth deep.
sibling
Returns the index’s sibling.
subtree_index_to_general
Translate the subtree index index rooted at root into a general index.