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 #
def
BinaryTree.indexOf
{α : Type u_1}
(lt : α → α → Prop)
[DecidableRel lt]
(x : α)
:
BinaryTree α → Option PosNum
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.
- BinaryTree.indexOf lt x BinaryTree.nil = none
Instances For
@[reducible, inline, deprecated BinaryTree.indexOf (since := "2026-06-07")]
Alias of BinaryTree.indexOf.
Equations
- Tree.indexOf lt x = BinaryTree.indexOf lt x
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
- BinaryTree.get x✝ BinaryTree.nil = none
- BinaryTree.get PosNum.one (BinaryTree.node a _t₁ _t₂) = some a
- BinaryTree.get n.bit0 (BinaryTree.node _a t₁ _t₂) = BinaryTree.get n t₁
- BinaryTree.get n.bit1 (BinaryTree.node _a _t₁ t₂) = BinaryTree.get n t₂
Instances For
@[reducible, inline, deprecated BinaryTree.get (since := "2026-06-07")]
Alias of BinaryTree.get.
Equations
- Tree.get n t = BinaryTree.get n t
Instances For
Retrieves an element from the tree, or the provided default value
if the index is invalid. See BinaryTree.get.
Equations
- BinaryTree.getOrElse n t v = (BinaryTree.get n t).getD v
Instances For
@[reducible, inline, deprecated BinaryTree.getOrElse (since := "2026-06-07")]
Alias of BinaryTree.getOrElse.
Equations
- Tree.getOrElse n t v = BinaryTree.getOrElse n t v