| 170 | } |
| 171 | |
| 172 | void insert(RBTreeNode* n, RBTreeNode* z) |
| 173 | { |
| 174 | auto y = nil; |
| 175 | auto x = root; |
| 176 | // 找到父节点 |
| 177 | while (x != nil) { |
| 178 | y = x; |
| 179 | if (z->k < x->k) { |
| 180 | x = x->left; |
| 181 | } else { |
| 182 | x = x->right; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | z->p = y; |
| 187 | y->addChild(this, z); |
| 188 | insert_fixup(z); |
| 189 | } |
| 190 | |
| 191 | void dumpInternal(RBTreeNode* n, int d) |
| 192 | { |