红黑树插入实现完成,如果检测其正确性呢?

This commit is contained in:
建峰 2024-06-25 18:02:47 +08:00
parent 411f0c1fa5
commit bd3258010a
2 changed files with 4 additions and 2 deletions

View File

@ -1124,6 +1124,7 @@ static bool tree_rb_rebalance(struct _tree* self, struct _tree_node* node)
} }
grandfather->color = RBT_RED; grandfather->color = RBT_RED;
tree_turn_right(self, grandfather); tree_turn_right(self, grandfather);
break;
} }
} }
else else
@ -1149,6 +1150,7 @@ static bool tree_rb_rebalance(struct _tree* self, struct _tree_node* node)
} }
grandfather->color = RBT_RED; grandfather->color = RBT_RED;
tree_turn_left(self, grandfather); tree_turn_left(self, grandfather);
break;
} }
} }
} }

View File

@ -249,6 +249,6 @@ void test_rbtree_num(void)
void test_tree(void) void test_tree(void)
{ {
test_avltree_num(); // test_avltree_num();
// test_rbtree_num(); test_rbtree_num();
} }