1 /* $Id: avl.h,v 1.2 1994/06/24 10:59:11 ceriel Exp $ */
3 /* AVL-trees: trees in which the difference in depth
4 of the left branch and the right branch is at most one.
5 Information in the nodes is represented by a pointer, which is to
6 be supplied by the user. The user is also expected to supply a
7 comparison routine for each AVL tree. This routine is offered two
8 parameters, both pointers, and is expected to return:
9 a negative number if the comparison result is <
10 0 if the comparison result is =
11 a positive number if the comparison result is >
14 typedef struct avl_tree *AVL_tree;
16 /* extern AVL_tree create_avl_tree(int (*cmp)());
17 Returns a fresh avl_tree structure. 'cmp' will be used as comparison
18 routine for this tree.
20 extern AVL_tree create_avl_tree();
22 /* extern add_to_avl_tree(AVL_tree tree, char *n);
23 Adds the information indicated by 'n' to the avl_tree indicated by 'tree'.
25 extern add_to_avl_tree();
27 /* extern char *find_ngt(AVL_tree tree, char *n);
28 Returns the information in the largest node that still compares <= to 'n',
31 extern char *find_ngt();
33 /* extern char *find_nlt(AVL_tree tree, char *n);
34 Returns the information in the largest node that still compares >= to 'n',
37 extern char *find_nlt();
39 /* extern char *find_eq(AVL_tree tree, char *n);
40 Returns the information in the node that compares equal to 'n',
43 extern char *find_eq();