Crate flat_tree [] [src]

You can represent a binary tree in a simple flat list using the following structure:

      3
  1       5
0   2   4   6  ...

This module exposes a series of functions to help you build and maintain this data structure.

See Also

Functions

children

Returns both children of a node.

children_with_depth

Returns both children of a node, with a depth.

count

Returns how many nodes are in the tree that the node spans.

count_with_depth

Returns how many nodes are in the tree that the node spans, with a depth.

depth

Returns the depth of a node.

full_roots

Returns all the previous fully rooted trees before the node.

index

Returns the flat-tree of the tree node at the specified depth and offset.

left_child

Returns only the left child of a node.

left_child_with_depth

Returns only the left child of a node, with a depth

left_span

Returns the left most node in the tree that it spans.

left_span_with_depth

Returns the left most node in the tree that the node spans, with a depth.

offset

Returns the offset of a node.

offset_with_depth

Returns the offset of a node with a depth.

parent

Returns the parent of a node.

parent_with_depth

Returns the parent of a node with a depth.

right_child

Returns only the left child of a node.

right_child_with_depth

Returns only the left child of a node, with a depth.

right_span

Returns the right most node in the tree that the node spans.

right_span_with_depth

Returns the right most node in the tree that the node spans, with a depth.

sibling

Returns the sibling of a node.

sibling_with_depth

Returns the sibling of a node with a depth.

spans

Returns the left and right most nodes in the tree that the node spans.

spans_with_depth

Returns the left and right most nodes in the tree that the node spans, with a depth.

uncle

Returns the parent's sibling, of a node.

uncle_with_depth

Returns the parent's sibling, of a node, with a depth.