module FlatTree
Extended Modules
Defined in:
flat_tree.criterator.cr
Instance Method Summary
-
#children(i : UInt64, d : UInt64? = self.depth(i)) : Array(UInt64)?
Returns an array [left_child, right_child] with the indexes of this elements children.
-
#count(i : UInt64, d : UInt64? = self.depth(i))
Returns how many nodes (including parent nodes) a tree contains
-
#depth(i : UInt64?) : UInt64
Returns the depth of an element
-
#full_roots(i : UInt64, nodes : Array(UInt64) = [] of UInt64)
Returns a list of all the full roots (subtrees where all nodes have either 2 or 0 children) < index.
-
#index(d : UInt64, o : UInt64) : UInt64
Returns an array index for the tree element at the given depth and offset
-
#iterator(i : UInt64 = 0_u64)
Create a stateful tree iterator starting at a given index.
-
#left_child(i : UInt64?, d : UInt64? = self.depth(i)) : UInt64?
Returns only the left child of a node.
-
#left_span(i : UInt64, d : UInt64? = self.depth(i))
Returns the left spanning in index in the tree index spans.
-
#offset(i : UInt64, d : UInt64? = self.depth(i)) : UInt64
Returns the relative offset of an element
-
#parent(i : UInt64, d : UInt64? = self.depth(i)) : UInt64
Returns the index of the parent element in tree
-
#right_child(i : UInt64?, d : UInt64? = self.depth(i)) : UInt64?
Returns only the right child of a node.
-
#right_span(i : UInt64, d : UInt64? = self.depth(i))
Returns the right spanning in index in the tree index spans.
-
#sibling(i : UInt64, d : UInt64? = self.depth(i))
Returns the index of this elements sibling
-
#spans(i : UInt64, d : UInt64? = self.depth(i))
Returns the range (inclusive) the tree root at index spans.
Instance Method Detail
Returns an array [left_child, right_child] with the indexes of this elements children. If this element does not have any children it returns null
Returns how many nodes (including parent nodes) a tree contains
Returns a list of all the full roots (subtrees where all nodes have either 2 or 0 children) < index. For example full_roots(8) returns [3] since the subtree rooted at 3 spans 0 -> 6 and the tree rooted at 7 has a child located at 9 which is >= 8.
Returns an array index for the tree element at the given depth and offset
Create a stateful tree iterator starting at a given index. The iterator exposes the following methods.
Returns only the left child of a node.
Returns the left spanning in index in the tree index spans.
Returns the relative offset of an element
Returns the index of the parent element in tree
Returns only the right child of a node.
Returns the right spanning in index in the tree index spans.
Returns the range (inclusive) the tree root at index spans. For example FlatTree.spans(3) would return [0, 6] (see the usage example).