Does the tree have no red right links, and at most one (left) red links in a row on any path?
(root: Option<NonNull<Node<K, V>>>, x: Option<NonNull<Node<K, V>>>)
| 400 | /// Does the tree have no red right links, and at most one (left) |
| 401 | /// red links in a row on any path? |
| 402 | fn is23<K, V>(root: Option<NonNull<Node<K, V>>>, x: Option<NonNull<Node<K, V>>>) -> bool { |
| 403 | if x.is_none() { |
| 404 | true |
| 405 | } else { |
| 406 | let x = NodeQuery::new(x); |
| 407 | let root = NodeQuery::new(root); |
| 408 | if x.right().is_red() || (x.node != root.node && x.is_red() && x.left().is_red()) { |
| 409 | false |
| 410 | } else { |
| 411 | is23(root.node, x.left().node) && is23(root.node, x.right().node) |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | fn calc_blacks<K, V>(x: Option<NonNull<Node<K, V>>>) -> usize { |
| 417 | let mut x = NodeQuery::new(x); |