| 336 | } |
| 337 | |
| 338 | void deleteInternal(RBTreeNode* z) |
| 339 | { |
| 340 | auto y = z; |
| 341 | auto origin_color = y->color; |
| 342 | RBTreeNode* x = nullptr; |
| 343 | |
| 344 | if (z->left == nil) { |
| 345 | x = z->right; |
| 346 | transplant(z, z->right); |
| 347 | } else if (z->right == nil) { |
| 348 | x = z->left; |
| 349 | transplant(z, z->left); |
| 350 | } else { |
| 351 | y = treeMinimum(z->right); |
| 352 | origin_color = y->color; |
| 353 | x = y->right; |
| 354 | if (y->p == z) { |
| 355 | x->p = y; |
| 356 | } else { |
| 357 | transplant(y, y->right); |
| 358 | y->right = z->right; |
| 359 | y->right->p = y; |
| 360 | } |
| 361 | transplant(z, y); |
| 362 | y->left = z->left; |
| 363 | y->left->p = y; |
| 364 | y->color = z->color; |
| 365 | } |
| 366 | if (origin_color == BLACK) { |
| 367 | deleteFixUp(x); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | void remove(int k) |
| 372 | { |
nothing calls this directly
no outgoing calls
no test coverage detected