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

Method len_recursive

rust/src/tree_structure.rs:20–34  ·  view source on GitHub ↗

Recursively count elements with proper arena access.

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

Source from the content-addressed store, hash-verified

18
19 /// Recursively count elements with proper arena access.
20 fn len_recursive(&self, node: &NodeRef<K, V>) -> usize {
21 match node {
22 NodeRef::Leaf(id, _) => self.get_leaf(*id).map(|leaf| leaf.len()).unwrap_or(0),
23 NodeRef::Branch(id, _) => self
24 .get_branch(*id)
25 .map(|branch| {
26 branch
27 .children
28 .iter()
29 .map(|child| self.len_recursive(child))
30 .sum()
31 })
32 .unwrap_or(0),
33 }
34 }
35
36 /// Returns true if the tree is empty.
37 pub fn is_empty(&self) -> bool {

Callers 1

lenMethod · 0.80

Calls 3

get_leafMethod · 0.80
get_branchMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected