src/tree/

This is basically our implementation of a segment tree in Solidity https://en.wikipedia.org/wiki/Segment_tree

Nodes are identified by Keys, and their walking procedure is handled by Routes.

We walk down starting from the root to the leftmost node of your range and then we walk to the right most root of your range. Along the way we will visit the nodes that constitute the required intervals such that the union of them all is your total range. We mark those nodes as "visit" nodes.

The exact walk procedure goes from the root to the lowest common ancestor (LCA) of your leftmost and rightmost visit node. Then we proceed from the LCA to the left node and then from the LCA to the right node before walking back up from the left node to the LCA, the right node to the LCA, and then the LCA to the root node.

Between each of those steps, a phase function is called to indicate the end of the previous phase so users can do any bookkeeping changes as necessary.

Last updated