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

Function del_min

src/tree/binary/rb2.rs:220–236  ·  view source on GitHub ↗

delete the min element rooted at h

(h: Option<NonNull<Node<K, V>>>)

Source from the content-addressed store, hash-verified

218
219/// delete the min element rooted at h
220fn del_min<K, V>(h: Option<NonNull<Node<K, V>>>) -> Option<NonNull<Node<K, V>>> {
221 let mut h = NodeQuery::new(h);
222
223 if h.left().is_none() {
224 if let Some(h) = h.node.take() {
225 Node::release(h);
226 }
227 None
228 } else {
229 if !h.left().is_red() && !h.left().left().is_red() {
230 h.node = move_red_left(h.node);
231 }
232 let new_left = del_min(h.left().node);
233 h.set_left(new_left);
234 balance(h.node)
235 }
236}
237
238/// delete the max element rooted at h
239fn del_max<K, V>(h: Option<NonNull<Node<K, V>>>) -> Option<NonNull<Node<K, V>>> {

Callers 2

delete_minMethod · 0.85
deleteFunction · 0.85

Calls 6

move_red_leftFunction · 0.85
balanceFunction · 0.85
is_noneMethod · 0.80
is_redMethod · 0.80
leftMethod · 0.45
set_leftMethod · 0.45

Tested by

no test coverage detected