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

Method get_first_leaf_id

rust/src/tree_structure.rs:120–139  ·  view source on GitHub ↗

Get the ID of the first (leftmost) leaf in the tree

(&self)

Source from the content-addressed store, hash-verified

118
119 /// Get the ID of the first (leftmost) leaf in the tree
120 pub fn get_first_leaf_id(&self) -> Option<NodeId> {
121 let mut current = &self.root;
122
123 loop {
124 match current {
125 NodeRef::Leaf(leaf_id, _) => return Some(*leaf_id),
126 NodeRef::Branch(branch_id, _) => {
127 if let Some(branch) = self.get_branch(*branch_id) {
128 if !branch.children.is_empty() {
129 current = &branch.children[0];
130 } else {
131 return None;
132 }
133 } else {
134 return None;
135 }
136 }
137 }
138 }
139 }
140
141 /// Find the leaf node and index where a key should be located.
142 /// Returns the leaf `NodeId` and the insertion index within that leaf.

Callers 4

resolve_range_boundsMethod · 0.80
newMethod · 0.80
analyze_next_call_workFunction · 0.80

Calls 2

get_branchMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected