view src/bst.h @ 4:5dfdc70e3025

Binary Search Tree in progress
author Eris Caffee <discordia@eldalin.com>
date Wed, 26 Sep 2012 10:48:01 -0500
parents
children b38243d51aea
line source
1 #ifndef BST_H_
2 #define BST_H_
4 #include <stddef.h>
5 #include <stdbool.h>
7 struct bst_node
8 {
9 struct bst_node * parent;
10 struct bst_node * left;
11 struct bst_node * right;
12 void * data;
13 };
15 struct bst
16 {
17 struct bst_node * root;
18 size_t size;
19 bool (*le)(void * a, void * b);
20 bool (*eq)(void * a, void * b);
21 };
23 struct bst * bst_new(bool (*le)(void * a, void * b), bool (*eq)(void * a, void * b));
24 void bst_delete(struct bst * bst);
26 void * bst_insert(struct bst * bst, void * data);
28 void * bst_search(struct bst * bst, void * data);
29 void * bst_search_iterative(struct bst * bst, void * data);
31 void * bst_minimum(struct bst * bst);
32 void * bst_maximum(struct bst * bst);
34 void bst_walk_inorder(struct bst * bst, void (*op)(void * data));
36 #endif