mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-07-03 15:56:52 +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)
|
||||
{
|
||||
node = tree_rb_turn_left(self, father);
|
||||
node->color = RBT_BLACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
father->color = RBT_BLACK;
|
||||
}
|
||||
grandfather->color = RBT_RED;
|
||||
node = tree_rb_turn_right(self, grandfather);
|
||||
break;
|
||||
@ -1264,8 +1268,12 @@ static bool tree_rb_rebalance(struct _tree* self, struct _tree_node* node)
|
||||
if(node == father->left)
|
||||
{
|
||||
node = tree_rb_turn_right(self, father);
|
||||
node->color = RBT_BLACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
father->color = RBT_BLACK;
|
||||
}
|
||||
grandfather->color = RBT_RED;
|
||||
node = tree_rb_turn_left(self, grandfather);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user