(tree: &mut RBTree<K, V>, x: *mut RBNode<K, V>)
| 842 | // 节点右旋 |
| 843 | #[inline] |
| 844 | unsafe fn right_rotate<K: Ord + Debug, V>(tree: &mut RBTree<K, V>, x: *mut RBNode<K, V>) { |
| 845 | /* |
| 846 | * x 处右旋 |
| 847 | * (x could also be the left child of p) |
| 848 | * |
| 849 | * p p |
| 850 | * \ \ |
| 851 | * x --> y |
| 852 | * / \ / \ |
| 853 | * y x |
| 854 | * / \ / \ |
| 855 | * c c |
| 856 | */ |
| 857 | |
| 858 | let p = (*x).parent; |
| 859 | let y = (*x).left; |
| 860 | let c = (*y).right; |
| 861 | |
| 862 | (*y).right = x; |
| 863 | (*x).parent = y; |
| 864 | (*x).left = c; |
| 865 | if !c.is_null() { |
| 866 | (*c).parent = x; |
| 867 | } |
| 868 | if p.is_null() { |
| 869 | tree.root = y; |
| 870 | } else if (*p).left == x { |
| 871 | (*p).left = y; |
| 872 | } else { |
| 873 | (*p).right = y; |
| 874 | } |
| 875 | (*y).parent = p; |
| 876 | } |
| 877 | |
| 878 | // 替换节点值并更新节点关系 |
| 879 | #[inline] |
no outgoing calls
no test coverage detected