mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-07-03 23:56:54 +08:00
我觉得这里是可以优化的,但是删除还是卡死。
This commit is contained in:
parent
e3f59e2b90
commit
454147ec81
@ -1242,8 +1242,12 @@ static bool tree_rb_rebalance(struct _tree* self, struct _tree_node* node)
|
|||||||
if(node == father->right)
|
if(node == father->right)
|
||||||
{
|
{
|
||||||
node = tree_rb_turn_left(self, father);
|
node = tree_rb_turn_left(self, father);
|
||||||
|
node->color = RBT_BLACK;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
father->color = RBT_BLACK;
|
father->color = RBT_BLACK;
|
||||||
|
}
|
||||||
grandfather->color = RBT_RED;
|
grandfather->color = RBT_RED;
|
||||||
node = tree_rb_turn_right(self, grandfather);
|
node = tree_rb_turn_right(self, grandfather);
|
||||||
break;
|
break;
|
||||||
@ -1264,8 +1268,12 @@ static bool tree_rb_rebalance(struct _tree* self, struct _tree_node* node)
|
|||||||
if(node == father->left)
|
if(node == father->left)
|
||||||
{
|
{
|
||||||
node = tree_rb_turn_right(self, father);
|
node = tree_rb_turn_right(self, father);
|
||||||
|
node->color = RBT_BLACK;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
father->color = RBT_BLACK;
|
father->color = RBT_BLACK;
|
||||||
|
}
|
||||||
grandfather->color = RBT_RED;
|
grandfather->color = RBT_RED;
|
||||||
node = tree_rb_turn_left(self, grandfather);
|
node = tree_rb_turn_left(self, grandfather);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user