mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-05-17 19:41:36 +08:00
红黑树调试通过
This commit is contained in:
parent
71ba5642ae
commit
590a50d9e7
@ -1339,7 +1339,7 @@ bool tree_rb_delete_fix(struct _tree* self, struct _tree_node* node)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(father->color = RBT_BLACK)
|
||||
if(father->color == RBT_BLACK)
|
||||
{
|
||||
// case 4
|
||||
// father is black, brother has no children
|
||||
@ -1388,7 +1388,7 @@ bool tree_rb_delete_fix(struct _tree* self, struct _tree_node* node)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(father->color = RBT_BLACK)
|
||||
if(father->color == RBT_BLACK)
|
||||
{
|
||||
// case4
|
||||
brother->color = RBT_RED;
|
||||
@ -1406,7 +1406,7 @@ bool tree_rb_delete_fix(struct _tree* self, struct _tree_node* node)
|
||||
|
||||
if(tmp != NULL && tmp->parent == NULL)
|
||||
{
|
||||
self->_root = node;
|
||||
self->_root = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,6 +155,10 @@ static bool tree_rb_check_color(struct _tree *self, struct _tree_node* root, int
|
||||
static bool tree_rb_check(struct _tree* self)
|
||||
{
|
||||
assert(self != NULL);
|
||||
if(self->_root == NULL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(self->_root->color != RBT_BLACK)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user