Commit 4990e7d4d908bbfd5ab890720bc107f912c92afa
1 parent
eacc711d
fix a small algorythmic bug introduced during optimization.
Showing
1 changed file
with
9 additions
and
4 deletions
| ... | ... | @@ -123,11 +123,15 @@ TR_treeDelete(TR_Tree * this, const void * search, TR_TreeComp comp) |
| 123 | 123 | } else { |
| 124 | 124 | TR_TREE_ROTATE(right, this, node->parent); |
| 125 | 125 | } |
| 126 | - } else { | |
| 127 | - // case 3/4 | |
| 128 | - if (NULL != sibling | |
| 126 | + sibling = TR_TREE_SIBLING(node); | |
| 127 | + } | |
| 128 | + | |
| 129 | + if (NULL == sibling | |
| 130 | + || (rbBlack == sibling->color | |
| 129 | 131 | && TR_TREE_NODE_BLACK(sibling->left) |
| 130 | - && TR_TREE_NODE_BLACK(sibling->right)) { | |
| 132 | + && TR_TREE_NODE_BLACK(sibling->right))) { | |
| 133 | + // case 3/4 | |
| 134 | + if (NULL != sibling) { | |
| 131 | 135 | sibling->color = rbRed; |
| 132 | 136 | } |
| 133 | 137 | |
| ... | ... | @@ -163,6 +167,7 @@ TR_treeDelete(TR_Tree * this, const void * search, TR_TreeComp comp) |
| 163 | 167 | |
| 164 | 168 | TR_TREE_ROTATE(left, this, sibling); |
| 165 | 169 | } |
| 170 | + sibling = TR_TREE_SIBLING(node); | |
| 166 | 171 | } |
| 167 | 172 | |
| 168 | 173 | // case 6 | ... | ... |
Please
register
or
login
to post a comment