]> git.sur5r.net Git - openldap/blob - include/avl.h
Add LDAP_TAG_LDAPCRED macro.
[openldap] / include / avl.h
1 /*
2  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted only
6  * as authorized by the OpenLDAP Public License.  A copy of this
7  * license is available at http://www.OpenLDAP.org/license.html or
8  * in file LICENSE in the top-level directory of the distribution.
9  */
10 /* Portions
11  * Copyright (c) 1993 Regents of the University of Michigan.
12  * All rights reserved.
13  *
14  * Redistribution and use in source and binary forms are permitted
15  * provided that this notice is preserved and that due credit is given
16  * to the University of Michigan at Ann Arbor. The name of the University
17  * may not be used to endorse or promote products derived from this
18  * software without specific prior written permission. This software
19  * is provided ``as is'' without express or implied warranty.
20  */
21 /* avl.h - avl tree definitions */
22
23
24 #ifndef _AVL
25 #define _AVL
26
27 #include <ldap_cdefs.h>
28
29 /*
30  * this structure represents a generic avl tree node.
31  */
32
33 LDAP_BEGIN_DECL
34
35 typedef struct avlnode Avlnode;
36
37 #ifdef AVL_INTERNAL
38 struct avlnode {
39         void*           avl_data;
40         signed int              avl_bf;
41         struct avlnode  *avl_left;
42         struct avlnode  *avl_right;
43 };
44
45 #define NULLAVL ((Avlnode *) NULL)
46
47 /* balance factor values */
48 #define LH      (-1)
49 #define EH      0
50 #define RH      1
51
52 /* avl routines */
53 #define avl_getone(x)   ((x) == 0 ? 0 : (x)->avl_data)
54 #define avl_onenode(x)  ((x) == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
55
56 #endif /* AVL_INTERNALS */
57
58 typedef int             (*AVL_APPLY) LDAP_P((void *, void*));
59 typedef int             (*AVL_CMP) LDAP_P((const void*, const void*));
60 typedef int             (*AVL_DUP) LDAP_P((void*, void*));
61 typedef void    (*AVL_FREE) LDAP_P((void*));
62
63 LDAP_F( int )
64 avl_free LDAP_P(( Avlnode *root, AVL_FREE dfree ));
65
66 LDAP_F( int )
67 avl_insert LDAP_P((Avlnode **, void*, AVL_CMP, AVL_DUP));
68
69 LDAP_F( void* )
70 avl_delete LDAP_P((Avlnode **, void*, AVL_CMP));
71
72 LDAP_F( void* )
73 avl_find LDAP_P((Avlnode *, const void*, AVL_CMP));
74
75 LDAP_F( void* )
76 avl_find_lin LDAP_P((Avlnode *, const void*, AVL_CMP));
77
78 #ifdef AVL_NONREENTRANT
79 LDAP_F( void* )
80 avl_getfirst LDAP_P((Avlnode *));
81
82 LDAP_F( void* )
83 avl_getnext LDAP_P((void));
84 #endif
85
86 LDAP_F( int )
87 avl_dup_error LDAP_P((void*, void*));
88
89 LDAP_F( int )
90 avl_dup_ok LDAP_P((void*, void*));
91
92 LDAP_F( int )
93 avl_apply LDAP_P((Avlnode *, AVL_APPLY, void*, int, int));
94
95 LDAP_F( int )
96 avl_prefixapply LDAP_P((Avlnode *, void*, AVL_CMP, void*, AVL_CMP, void*, int));
97
98 /* apply traversal types */
99 #define AVL_PREORDER    1
100 #define AVL_INORDER     2
101 #define AVL_POSTORDER   3
102 /* what apply returns if it ran out of nodes */
103 #define AVL_NOMORE      (-6)
104
105 LDAP_END_DECL
106
107 #endif /* _AVL */