does every path from the root to a leaf have the given number of black links?
(root: Option<NonNull<Node<K, V>>>)
| 356 | |
| 357 | /// does every path from the root to a leaf have the given number of black links? |
| 358 | fn is_balance<K, V>(root: Option<NonNull<Node<K, V>>>) -> bool { |
| 359 | fn counter<K, V>(h: Option<NonNull<Node<K, V>>>, mut black: usize) -> bool { |
| 360 | if h.is_none() { |
| 361 | 0 == black |
| 362 | } else { |
| 363 | let h = NodeQuery::new(h); |
| 364 | if !h.is_red() { |
| 365 | black -= 1; |
| 366 | } |
| 367 | counter(h.left().node, black) && counter(h.right().node, black) |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | let black = calc_blacks(root); |
| 372 | counter(root, black) |
| 373 | } |
| 374 | |
| 375 | /// Assuming that h is red and both h.left and h.left.left |
| 376 | /// are black, make h.left or one of its children red. |
nothing calls this directly
no test coverage detected