| 87 | } |
| 88 | |
| 89 | NodeIndex |
| 90 | NodeIndex::root(LeafCount n) |
| 91 | { |
| 92 | if (n.val == 0) { |
| 93 | throw std::runtime_error("Root for zero-size tree is undefined"); |
| 94 | } |
| 95 | |
| 96 | auto w = NodeCount(n); |
| 97 | return NodeIndex{ (one << log2(w.val)) - 1 }; |
| 98 | } |
| 99 | |
| 100 | bool |
| 101 | NodeIndex::is_leaf() const |