blob: fad8bbdd4cd629df45325718d771feab0bd36e33 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001
2#ifndef _BINTREE_H_
3#define _BINTREE_H_
4
5struct bintree_node
6{
7 struct bintree *tree;
8
9 struct bintree_node *parent;
10 int parent_link;
11
12#define BL_LEFT 0
13#define BL_RIGHT 1
14#define BL_MAX 2
15 struct bintree_node *link[BL_MAX];
16#define bl_left link[BL_LEFT]
17#define bl_right link[BL_RIGHT]
18
19 void *data;
20};
21
22struct bintree
23{
24 int count;
25 struct bintree_node *root;
26
27 int (*cmp) (void *, void *);
28};
29
30void *bintree_lookup (void *data, struct bintree *tree);
31void *bintree_lookup_min (struct bintree *tree);
32void *bintree_lookup_max (struct bintree *tree);
33
34int bintree_add (void *data, struct bintree *tree);
35int bintree_remove (void *data, struct bintree *tree);
36
37void bintree_head (struct bintree *tree, struct bintree_node *node);
38int bintree_end (struct bintree_node *node);
39void bintree_next (struct bintree_node *node);
40
41struct bintree *bintree_create ();
42void bintree_delete (struct bintree *);
43
44void bintree_print (void (*print) (int, void *), struct bintree *);
45
46#endif /*_BINTREE_H_*/
47