MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / find_parent

Method find_parent

nodedb-spatial/src/rtree/tree.rs:96–108  ·  view source on GitHub ↗

Find parent of a node by traversal from root.

(&self, current: usize, target: usize)

Source from the content-addressed store, hash-verified

94
95 /// Find parent of a node by traversal from root.
96 pub(crate) fn find_parent(&self, current: usize, target: usize) -> Option<usize> {
97 if let NodeKind::Internal { children } = &self.nodes[current].kind {
98 for child in children {
99 if child.node_idx == target {
100 return Some(current);
101 }
102 if let Some(p) = self.find_parent(child.node_idx, target) {
103 return Some(p);
104 }
105 }
106 }
107 None
108 }
109
110 /// Condense root: if root is internal with 1 child, collapse.
111 pub(crate) fn condense_root(&mut self) {

Callers 1

split_nodeFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected