|
|
@ -171,6 +171,12 @@ void rotate_right(TreeAlloc **root_ptr, TreeAlloc *ta) { |
|
|
|
|
|
|
|
void repair_tree_after_insert(TreeAlloc **root_ptr, TreeAlloc *ta) { |
|
|
|
TreeAlloc *parent = ta->parent; |
|
|
|
#ifdef DEBUG |
|
|
|
printf("=== PRE-INSERT-FIXUP ===\n"); |
|
|
|
printf("===== CURRENT TREE =====\n"); |
|
|
|
debug_print_tree(0, *root_ptr); |
|
|
|
printf("===== END OF TREES =====\n"); |
|
|
|
#endif |
|
|
|
|
|
|
|
if (parent == NULL) { |
|
|
|
ta->color = COLOR_BLACK; |
|
|
@ -206,6 +212,12 @@ void repair_tree_after_insert(TreeAlloc **root_ptr, TreeAlloc *ta) { |
|
|
|
grandparent->color = COLOR_RED; |
|
|
|
} |
|
|
|
} |
|
|
|
#ifdef DEBUG |
|
|
|
printf("== POST-INSERT-FIXUP ===\n"); |
|
|
|
printf("===== CURRENT TREE =====\n"); |
|
|
|
debug_print_tree(0, *root_ptr); |
|
|
|
printf("===== END OF TREES =====\n"); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void replace_node(TreeAlloc **root_ptr, TreeAlloc *node, TreeAlloc *replace) { |
|
|
|