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

Method deleteInternal

templates/rb.cpp:378–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376 }
377
378 void deleteInternal(RBTreeNode* z)
379 {
380 auto y = z;
381 auto origin_color = y->color;
382 RBTreeNode* x = nullptr;
383
384 if (z->left == nil) {
385 x = z->right;
386 transplant(z, z->right);
387 } else if (z->right == nil) {
388 x = z->left;
389 transplant(z, z->left);
390 } else {
391 y = treeMinimum(z->right);
392 origin_color = y->color;
393 x = y->right;
394 if (y->p == z) {
395 x->p = y;
396 } else {
397 transplant(y, y->right);
398 y->right = z->right;
399 y->right->p = y;
400 }
401 transplant(z, y);
402 y->left = z->left;
403 y->left->p = y;
404 y->color = z->color;
405 }
406 if (origin_color == BLACK) {
407 deleteFixUp(x);
408 }
409 }
410
411 void remove(int k)
412 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected