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

Method rightRotate

templates/red-black-tree.cpp:111–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected