MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / leaf_count_recursive

Method leaf_count_recursive

rust/src/tree_structure.rs:52–66  ·  view source on GitHub ↗

Recursively count leaf nodes with proper arena access.

(&self, node: &NodeRef<K, V>)

Source from the content-addressed store, hash-verified

50
51 /// Recursively count leaf nodes with proper arena access.
52 fn leaf_count_recursive(&self, node: &NodeRef<K, V>) -> usize {
53 match node {
54 NodeRef::Leaf(_, _) => 1, // An arena leaf is one leaf node
55 NodeRef::Branch(id, _) => self
56 .get_branch(*id)
57 .map(|branch| {
58 branch
59 .children
60 .iter()
61 .map(|child| self.leaf_count_recursive(child))
62 .sum()
63 })
64 .unwrap_or(0),
65 }
66 }
67
68 /// Clear all items from the tree.
69 pub fn clear(&mut self) {

Callers 1

leaf_countMethod · 0.80

Calls 1

get_branchMethod · 0.80

Tested by

no test coverage detected