delete the max element rooted at h
(h: Option<NonNull<Node<K, V>>>)
| 237 | |
| 238 | /// delete the max element rooted at h |
| 239 | fn del_max<K, V>(h: Option<NonNull<Node<K, V>>>) -> Option<NonNull<Node<K, V>>> { |
| 240 | let mut h = NodeQuery::new(h); |
| 241 | |
| 242 | if h.left().is_red() { |
| 243 | h.node = rotate_right(h.node); |
| 244 | } |
| 245 | |
| 246 | if h.right().is_none() { |
| 247 | if let Some(h) = h.node.take() { |
| 248 | Node::release(h); |
| 249 | } |
| 250 | None |
| 251 | } else { |
| 252 | if !h.right().is_red() && !h.right().left().is_red() { |
| 253 | h.node = move_red_right(h.node); |
| 254 | } |
| 255 | let new_right = del_max(h.right().node); |
| 256 | h.set_right(new_right); |
| 257 | balance(h.node) |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | fn delete<K, V>(h: Option<NonNull<Node<K, V>>>, key: &K) -> Option<NonNull<Node<K, V>>> |
| 262 | where |
no test coverage detected