Compute the height of a sub-tree.
(nodeId int)
| 651 | |
| 652 | // Compute the height of a sub-tree. |
| 653 | func (tree B2DynamicTree) ComputeHeight(nodeId int) int { |
| 654 | B2Assert(0 <= nodeId && nodeId < tree.M_nodeCapacity) |
| 655 | node := &tree.M_nodes[nodeId] |
| 656 | |
| 657 | if node.IsLeaf() { |
| 658 | return 0 |
| 659 | } |
| 660 | |
| 661 | height1 := tree.ComputeHeight(node.Child1) |
| 662 | height2 := tree.ComputeHeight(node.Child2) |
| 663 | return 1 + MaxInt(height1, height2) |
| 664 | } |
| 665 | |
| 666 | func (tree B2DynamicTree) ComputeTotalHeight() int { |
| 667 | return tree.ComputeHeight(tree.M_root) |
no test coverage detected