summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7f561ff)
raw | patch | inline | side by side (parent: 7f561ff)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 3 Dec 2006 13:29:43 +0000 (14:29 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 3 Dec 2006 13:29:43 +0000 (14:29 +0100) |
It's broken due to the asserts right now, but this only means I haven't found
another bug yet.
another bug yet.
src/utils_avltree.c | patch | blob | history |
diff --git a/src/utils_avltree.c b/src/utils_avltree.c
index 275cb9b37acb6c651d55cbb301797c3e22723a07..f2c5d06f988aac752ccaa7f0085c56aa04c46b74 100644 (file)
--- a/src/utils_avltree.c
+++ b/src/utils_avltree.c
if (height_new == n->height)
break;
+ /* FIXME */
+ if (n->left != NULL)
+ {
+ cmp = BALANCE(n->left);
+ assert ((cmp >= -1) && (cmp <= 1));
+ }
+ if (n->right != NULL)
+ {
+ cmp = BALANCE(n->right);
+ assert ((cmp >= -1) && (cmp <= 1));
+ }
+
n->height = height_new;
cmp = height_right - height_left;
else
l->parent->right = l;
}
+
+ height_left = (n->left == NULL) ? 0 : n->left->height;
+ height_right = (n->right == NULL) ? 0 : n->right->height;
+ height_new = 1 + ((height_left > height_right) ? height_left : height_right);
+ cmp = BALANCE(n);
+ assert (height_new < n->height);
+ assert ((cmp >= -1) || (cmp <= 1));
+ n->height = height_new;
+
+ height_left = (l->left == NULL) ? 0 : l->left->height;
+ height_right = (l->right == NULL) ? 0 : l->right->height;
+ height_new = 1 + ((height_left > height_right) ? height_left : height_right);
+ cmp = BALANCE(l);
+ assert (height_new >= l->height);
+ assert ((cmp >= -1) || (cmp <= 1));
+ l->height = height_new;
+
+ n = l->parent;
}
else if (cmp > 1)
{
else
r->parent->right = r;
}
+
+ height_left = (n->left == NULL) ? 0 : n->left->height;
+ height_right = (n->right == NULL) ? 0 : n->right->height;
+ height_new = 1 + ((height_left > height_right) ? height_left : height_right);
+ cmp = BALANCE(n);
+ assert (height_new < n->height);
+ assert ((cmp >= -1) || (cmp <= 1));
+ n->height = height_new;
+
+ height_left = (r->left == NULL) ? 0 : r->left->height;
+ height_right = (r->right == NULL) ? 0 : r->right->height;
+ height_new = 1 + ((height_left > height_right) ? height_left : height_right);
+ cmp = BALANCE(r);
+ assert (height_new >= r->height);
+ assert ((cmp >= -1) || (cmp <= 1));
+ r->height = height_new;
+
+ n = r->parent;
}
else
{