mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-05-18 03:51:35 +08:00
修改插入修复完成后,没有把grandfather重新赋值给node的bug
This commit is contained in:
parent
571b28fb4f
commit
bbc21c85a3
16
src/tree.c
16
src/tree.c
@ -1168,14 +1168,10 @@ static bool tree_rb_rebalance(struct _tree* self, struct _tree_node* node)
|
|||||||
if(node == father->right)
|
if(node == father->right)
|
||||||
{
|
{
|
||||||
node = tree_turn_left(self, father);
|
node = tree_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;
|
||||||
tree_turn_right(self, grandfather);
|
node = tree_turn_right(self, grandfather);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1194,14 +1190,10 @@ static bool tree_rb_rebalance(struct _tree* self, struct _tree_node* node)
|
|||||||
if(node == father->left)
|
if(node == father->left)
|
||||||
{
|
{
|
||||||
node = tree_turn_right(self, father);
|
node = tree_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;
|
||||||
tree_turn_left(self, grandfather);
|
node = tree_turn_left(self, grandfather);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user