MCPcopy Create free account
hub / github.com/douchuan/algorithm / find

Function find

src/tree/binary/bst.rs:108–117  ·  view source on GitHub ↗

# Safety This is highly unsafe, due to pointer

(node: Option<NonNull<Node<K, V>>>, key: &K)

Source from the content-addressed store, hash-verified

106///
107/// This is highly unsafe, due to pointer
108pub unsafe fn find<K, V>(node: Option<NonNull<Node<K, V>>>, key: &K) -> Option<NonNull<Node<K, V>>>
109where
110 K: Ord,
111{
112 node.and_then(|node| match node.as_ref().key.cmp(key) {
113 Ordering::Less => find(node.as_ref().right, key),
114 Ordering::Greater => find(node.as_ref().left, key),
115 Ordering::Equal => Some(node),
116 })
117}
118
119/// # Safety
120///

Callers 6

deleteMethod · 0.70
getMethod · 0.70
succFunction · 0.70
predFunction · 0.70
getMethod · 0.70
containsMethod · 0.70

Calls 1

cmpMethod · 0.45

Tested by

no test coverage detected