Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ramo* RBTreeSuccessor(void *raiz , void* x) {
- tree_t *this = (tree_t*) raiz;
- ramo *this_2 = (ramo*) x;
- if (this_2->right != this->nulo) {
- return tree_minimum(raiz ,this_2->right);
- }
- ramo* y = this_2->parent;
- while (y != this_2 && x == y->right) {
- this_2 = y;
- y = y->parent;
- }
- return y;
- }
- void* RBTreeDelete(void* tree, void *z) {
- tree_t *raiz = (tree_t*) tree;
- ramo* this = (ramo*) z;
- ramo *x, *y;
- if (this->left == raiz->nulo || this->right == raiz->nulo) {
- y = z;
- } else {
- y = RBTreeSuccessor(tree, z);
- }
- if (y->left != raiz->nulo) {
- x = y->left;
- } else {
- x = y->right;
- }
- //去掉了判断条件
- x->parent = y->parent;
- if (y->parent == raiz->nulo) {
- tree = x;
- } else if (y == y->parent->left) {
- y->parent->left = x;
- } else {
- y->parent->right = x;
- }
- if (y != z) {
- this->data = y->data;
- }
- if (y->cor == BLACK) {
- delete_fix_up(tree, x);
- }
- return y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement