if (node->child[1])
nodes += add_to_relocation_list(node->child[1], head);
+ if (debug) {
+ printf("Adding node %p to relocation list\n", node);
+ fflush(stdout);
+ }
+
list_add(&node->list, head);
nodes++;
struct quadtree_ops *ops)
{
struct quadtree *tmp = start, *node;
- int i;
+ int i, d = nodes / 2;
+
+ while (nodes) {
+ if (debug) {
+ printf("stepping %d, %d nodes left\n", d, nodes);
+ fflush(stdout);
+ }
+
+ for (i = 0; i < d; i++)
+ tmp = list_to_tree(tmp->list.next);
+
+ if (debug) {
+ printf("Now moving mode %p\n", tmp);
+ fflush(stdout);
+ }
+
+ node = list_to_tree(tmp->list.next);
+ list_del(&node->list);
+ quadtree_add(parent, node, ops);
+ nodes--;
+
+ d /= 2;
+ if (d == 0)
+ d = nodes / 2;
+ }
+
+ return;
for (i = 0; i < nodes / 2; i++)
tmp = list_to_tree(tmp->list.next);
tmp = list_to_tree(node->list.prev);
if (debug) {
+ printf("%d nodes to move, now at %d\n", nodes, i);
printf("Moving node %p\n", node);
fflush(stdout);
}
struct list_head *head = NULL;
int i, nodes = 0;
+ validate_tree(node);
+
if (debug) {
printf("Deleting node %p under parent %p\n",
node, node->parent);
+ printf("Relocating %d children\n", node->children);
fflush(stdout);
}
/*