(tree: &mut RBTree<K, V>, x: *mut RBNode<K, V>)
| 806 | // 节点左旋 |
| 807 | #[inline] |
| 808 | unsafe fn left_rotate<K: Ord + Debug, V>(tree: &mut RBTree<K, V>, x: *mut RBNode<K, V>) { |
| 809 | /* |
| 810 | * x 处左旋 |
| 811 | * (x could also be the left child of p) |
| 812 | * |
| 813 | * p p |
| 814 | * \ \ |
| 815 | * x --> y |
| 816 | * / \ / \ |
| 817 | * y x |
| 818 | * / \ / \ |
| 819 | * c c |
| 820 | */ |
| 821 | |
| 822 | let p = (*x).parent; |
| 823 | let y = (*x).right; |
| 824 | let c = (*y).left; |
| 825 | |
| 826 | (*y).left = x; |
| 827 | (*x).parent = y; |
| 828 | (*x).right = c; |
| 829 | if !c.is_null() { |
| 830 | (*c).parent = x; |
| 831 | } |
| 832 | if p.is_null() { |
| 833 | tree.root = y; |
| 834 | } else if (*p).left == x { |
| 835 | (*p).left = y; |
| 836 | } else { |
| 837 | (*p).right = y; |
| 838 | } |
| 839 | (*y).parent = p; |
| 840 | } |
| 841 | |
| 842 | // 节点右旋 |
| 843 | #[inline] |
no outgoing calls
no test coverage detected