mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-05-18 03:51:35 +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
|
else
|
||||||
{
|
{
|
||||||
if(father->color = RBT_BLACK)
|
if(father->color == RBT_BLACK)
|
||||||
{
|
{
|
||||||
// case 4
|
// case 4
|
||||||
// father is black, brother has no children
|
// father is black, brother has no children
|
||||||
@ -1388,7 +1388,7 @@ bool tree_rb_delete_fix(struct _tree* self, struct _tree_node* node)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(father->color = RBT_BLACK)
|
if(father->color == RBT_BLACK)
|
||||||
{
|
{
|
||||||
// case4
|
// case4
|
||||||
brother->color = RBT_RED;
|
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)
|
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)
|
static bool tree_rb_check(struct _tree* self)
|
||||||
{
|
{
|
||||||
assert(self != NULL);
|
assert(self != NULL);
|
||||||
|
if(self->_root == NULL)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(self->_root->color != RBT_BLACK)
|
if(self->_root->color != RBT_BLACK)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user