1/* binary tree node, such that keys are sorted lexicographically for fast lookup */
2struct treenode {
3 char *key;
4 void *value;
5 struct treenode *child[2];
6 int height;
7};
8
9/* free a tree and its children recursively, free keys and values with a function */
10void deltree(struct treenode *, void(void *), void(void *));
11/* search a binary tree for a key, return the key's value or NULL */
12struct treenode *treefind(struct treenode *, const char *);
13/* insert into a binary tree a key and a value, replace and return the old value if the key already exists */
14void *treeinsert(struct treenode **, char *, void *);