MCPcopy Create free account
hub / github.com/acm-clan/algorithm-stone / rightRotate

Method rightRotate

templates/rb.cpp:130–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128 }
129
130 void rightRotate(RBTreeNode* x)
131 {
132 // x右移,x的左孩子y成为根节点,y的右孩子成为x的左孩子,其他不动
133 // 看起来就像是x右移了
134 auto y = x->left;
135
136 x->left = y->right;
137
138 // 更新right的父节点
139 if (y->right != nil) {
140 y->right->p = x;
141 }
142
143 y->p = x->p;
144
145 transplant(x, y);
146
147 y->right = x;
148 x->p = y;
149 }
150
151 RBTreeNode* getInternal(RBTreeNode* n, int k)
152 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected