| 109 | } |
| 110 | |
| 111 | void rightRotate(RBTreeNode* x) |
| 112 | { |
| 113 | // x右移,x的左孩子y成为根节点,y的右孩子成为x的左孩子,其他不动 |
| 114 | // 看起来就像是x右移了 |
| 115 | auto y = x->left; |
| 116 | |
| 117 | x->left = y->right; |
| 118 | |
| 119 | // 更新right的父节点 |
| 120 | if (y->right != nil) { |
| 121 | y->right->p = x; |
| 122 | } |
| 123 | |
| 124 | y->p = x->p; |
| 125 | |
| 126 | transplant(x, y); |
| 127 | |
| 128 | y->right = x; |
| 129 | x->p = y; |
| 130 | } |
| 131 | |
| 132 | RBTreeNode* getInternal(RBTreeNode* n, int k) |
| 133 | { |
nothing calls this directly
no outgoing calls
no test coverage detected