Exemple #1
0
void test_initialize_quadtree ( void )
{
  QuadTree * qt = init_quadtree(sizeof(int));

  ASSERT ( qt, "NULL quadtree");

  destroy_quadtree(qt);
}
Exemple #2
0
void test_insert_points ( void ) {
  QuadTree * qt = init_quadtree(sizeof(int));

  int i;

  srand(1234567);

  for ( i = 0; i < 5000; i += 1 ) {
    Point pt;
    pt.x = rand();
    pt.y = rand();
    qt_insert(qt, &pt, i);
  }

  qt_traverse(qt, print_qt_node_int_pointer);

  destroy_quadtree(qt);
}
Exemple #3
0
int
main(int argc, char *argv[]) {
        quadtree_t *root;
        char str[8];
        int x1, y1;
        int x2, y2;
        int l;
        int t;
        while (scanf("%d", &t) != EOF) {
                tot = 0;
                root = init_quadtree(100);
                while (t--) {
                        scanf("%s %d %d %d", str, &x1, &y1, &l);
                        x2 = x1 + l - 1;
                        y2 = y1 + l - 1;
                        if (str[0] == 'T') {
                                printf("%d\n", quadtree_query(root, x1, y1, x2, y2));
                        } else {
                                quadtree_set(root, x1, y1, x2, y2, str[0] == 'W' ? WHITE : BLACK);
                        }
                }
        }
        return 0;
}