Binary tree get operation #
In this file we define Tree.indexOf
, Tree.get
, and Tree.getOrElse
.
These definitions were moved from the main file to avoid a dependency on Num
.
References #
Finds the index of an element in the tree assuming the tree has been constructed according to the provided decidable order on its elements. If it hasn't, the result will be incorrect. If it has, but the element is not in the tree, returns none.
Equations
- One or more equations did not get rendered due to their size.
- Tree.indexOf lt x Tree.nil = none
Instances For
Retrieves an element uniquely determined by a PosNum
from the tree,
taking the following path to get to the element:
bit0
- go to left childbit1
- go to right childPosNum.one
- retrieve from here
Equations
Instances For
Retrieves an element from the tree, or the provided default value
if the index is invalid. See Tree.get
.
Equations
- Tree.getOrElse n t v = (Tree.get n t).getD v