Skip to content

Commit e8fc083

Browse files
author
fuli
committed
fix a bug in interval_tree ,same as dos-tree
1 parent ab238a0 commit e8fc083

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

include/interval_tree.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ namespace alg
118118
rbtree_node child;
119119
if (n == NULL) return;
120120

121-
/* Copy key/value from predecessor and then delete it instead */
121+
/* Copy fields from predecessor and then delete it instead */
122122
if (n->left != NULL && n->right != NULL) {
123123
ivltree_node pred = IVLNODE(maximum_node(n->left));
124124
n->low = pred->low;
@@ -135,7 +135,14 @@ namespace alg
135135
n->color = node_color(child);
136136
delete_case1(n);
137137
}
138+
138139
replace_node(n, child);
140+
// copy child value if exists, add your fields if you got one
141+
if (child != NULL) {
142+
IVLNODE(n)->low = IVLNODE(child)->low;
143+
IVLNODE(n)->high = IVLNODE(child)->high;
144+
}
145+
139146
if (n->parent == NULL && child != NULL)
140147
child->color = BLACK;
141148

0 commit comments

Comments
 (0)