abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
avl.h
Go to the documentation of this file.
1 /*
2  * Revision Control Information
3  *
4  * $Source: /vol/opua/opua2/sis/sis-1.2/common/src/sis/avl/RCS/avl.h,v $
5  * $Author: sis $
6  * $Revision: 1.3 $
7  * $Date: 1994/07/15 23:00:40 $
8  *
9  */
10 #ifndef ABC__misc__avl__avl_h
11 #define ABC__misc__avl__avl_h
12 
13 
15 
16 
17 #define EXTERN
18 
19 #ifndef ARGS
20 #define ARGS(protos) protos
21 #endif
22 
23 #define MAX(a,b) ((a) > (b) ? (a) : (b))
24 
25 #define NIL(type) \
26  ((type *) 0)
27 #define ALLOC(type, num) \
28  ((type *) malloc(sizeof(type) * (num)))
29 #define REALLOC(type, obj, num) \
30  ((type *) realloc((char *) obj, sizeof(type) * (num)))
31 #define FREE(obj) \
32  free((char *) (obj))
33 
34 
35 
36 typedef struct avl_node_struct avl_node;
39  char *key;
40  char *value;
41  int height;
42 };
43 
44 
45 typedef struct avl_tree_struct avl_tree;
48  int (*compar)();
50  int modified;
51 };
52 
53 
58  int count;
59 };
60 
61 
62 #define AVL_FORWARD 0
63 #define AVL_BACKWARD 1
64 
65 
66 EXTERN avl_tree *avl_init_table ARGS((int (*)()));
67 EXTERN int avl_delete ARGS((avl_tree *, char **, char **));
68 EXTERN int avl_insert ARGS((avl_tree *, char *, char *));
69 EXTERN int avl_lookup ARGS((avl_tree *, char *, char **));
70 EXTERN int avl_first ARGS((avl_tree *, char **, char **));
71 EXTERN int avl_last ARGS((avl_tree *, char **, char **));
72 EXTERN int avl_find_or_add ARGS((avl_tree *, char *, char ***));
73 EXTERN int avl_count ARGS((avl_tree *));
74 EXTERN int avl_numcmp ARGS((char *, char *));
75 EXTERN int avl_gen ARGS((avl_generator *, char **, char **));
76 EXTERN void avl_foreach ARGS((avl_tree *, void (*)(), int));
77 EXTERN void avl_free_table ARGS((avl_tree *, void (*)(), void (*)()));
80 
81 #define avl_is_member(tree, key) avl_lookup(tree, key, (char **) 0)
82 
83 #define avl_foreach_item(table, gen, dir, key_p, value_p) \
84  for(gen = avl_init_gen(table, dir); \
85  avl_gen(gen, key_p, value_p) || (avl_free_gen(gen),0);)
86 
87 
88 
90 
91 #endif
int num_entries
Definition: avl.h:49
#define EXTERN
Definition: avl.h:17
int height
Definition: avl.h:41
void avl_free_table(avl_tree *tree, void(*)() key_free, void(*)() value_free)
Definition: avl.c:519
avl_find_or_add(avl_tree *tree, char *key, char ***slot_p)
Definition: avl.c:170
void avl_free_gen(avl_generator *gen)
Definition: avl.c:338
avl_delete(avl_tree *tree, char **key_p, char **value_p)
Definition: avl.c:207
avl_insert(avl_tree *tree, char *key, char *value)
Definition: avl.c:136
char * key
Definition: avl.h:39
int avl_count(avl_tree *tree)
Definition: avl.c:530
void avl_foreach(avl_tree *tree, void(*)() func, int direction)
Definition: avl.c:483
avl_node ** nodelist
Definition: avl.h:57
avl_node * root
Definition: avl.h:47
avl_last(avl_tree *tree, char **key_p, char **value_p)
Definition: avl.c:111
int modified
Definition: avl.h:50
int(* compar)()
Definition: avl.h:48
#define ARGS(protos)
Definition: avl.h:20
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
avl_gen(avl_generator *gen, char **key_p, char **value_p)
Definition: avl.c:314
char * value
Definition: avl.h:40
avl_tree * tree
Definition: avl.h:56
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
avl_tree * avl_init_table(int(*)() compar)
Definition: avl.c:47
avl_lookup(avl_tree *tree, char *key, char **value_p)
Definition: avl.c:61
avl_first(avl_tree *tree, char **key_p, char **value_p)
Definition: avl.c:85
avl_generator * avl_init_gen(avl_tree *tree, int dir)
Definition: avl.c:287
avl_node * left
Definition: avl.h:38
avl_node * right
Definition: avl.h:38
int avl_numcmp(char *x, char *y)
Definition: avl.c:553