]> git.itanic.dy.fi Git - sdl-planets/blob - quadtree.h
quadtree: Add missing function definition to the header
[sdl-planets] / quadtree.h
1 #ifndef _QUADTREE_H_
2 #define _QUADTREE_H_
3
4 struct quadtree {
5         struct quadtree *child[4];
6         struct quadtree *parent;
7 };
8
9 static inline void init_quadtree(struct quadtree *t)
10 {
11         int i;
12
13         for (i = 0; i < 4; i++)
14                 t->child[i] = 0;
15         t->parent = 0;
16 }
17
18 #define QUADTREE_UPLEFT         0x1
19 #define QUADTREE_UPRIGHT        0x2
20 #define QUADTREE_DOWNLEFT       0x4
21 #define QUADTREE_DOWNRIGHT      0x8
22 #define QUADTREE_SELF           0x10
23
24 struct quadtree_iterator {
25         struct quadtree *head;
26         void *ptr;
27
28         int (*direction)(struct quadtree *head, void *ptr);
29         void (*callback)(struct quadtree *head, void *ptr);
30 };
31
32 struct quadtree *quadtree_add(struct quadtree *parent,
33                               struct quadtree *new,
34                               int (*compare)(struct quadtree *a,
35                                              struct quadtree *b));
36
37 int walk_tree(const struct quadtree_iterator *iterator);
38
39 #endif