tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
avltree.h
Go to the documentation of this file.
1 /* =============================================================================
2  *
3  * avltree.h
4  * -- AVL balanced tree library
5  *
6  * =============================================================================
7  *
8  * AVL balanced tree library
9  *
10  * > Created (Julienne Walker): June 17, 2003
11  * > Modified (Julienne Walker): September 24, 2005
12  *
13  * This code is in the public domain. Anyone may
14  * use it or change it in any way that they see
15  * fit. The author assumes no responsibility for
16  * damages incurred through use of the original
17  * code or any variations thereof.
18  *
19  * It is requested, but not required, that due
20  * credit is given to the original author and
21  * anyone who has modified the code through
22  * a header comment, such as this one.
23  *
24  * =============================================================================
25  *
26  * Modified May 5, 2006 by Chi Cao Minh
27  *
28  * - Changed to not need functions to duplicate and release the data pointer
29  *
30  * =============================================================================
31  *
32  * For the license of bayes/sort.h and bayes/sort.c, please see the header
33  * of the files.
34  *
35  * ------------------------------------------------------------------------
36  *
37  * For the license of kmeans, please see kmeans/LICENSE.kmeans
38  *
39  * ------------------------------------------------------------------------
40  *
41  * For the license of ssca2, please see ssca2/COPYRIGHT
42  *
43  * ------------------------------------------------------------------------
44  *
45  * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
46  * header of the files.
47  *
48  * ------------------------------------------------------------------------
49  *
50  * For the license of lib/rbtree.h and lib/rbtree.c, please see
51  * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
52  *
53  * ------------------------------------------------------------------------
54  *
55  * Unless otherwise noted, the following license applies to STAMP files:
56  *
57  * Copyright (c) 2007, Stanford University
58  * All rights reserved.
59  *
60  * Redistribution and use in source and binary forms, with or without
61  * modification, are permitted provided that the following conditions are
62  * met:
63  *
64  * * Redistributions of source code must retain the above copyright
65  * notice, this list of conditions and the following disclaimer.
66  *
67  * * Redistributions in binary form must reproduce the above copyright
68  * notice, this list of conditions and the following disclaimer in
69  * the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * * Neither the name of Stanford University nor the names of its
73  * contributors may be used to endorse or promote products derived
74  * from this software without specific prior written permission.
75  *
76  * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
77  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
78  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
79  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
80  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
81  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
82  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
83  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
84  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
85  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
86  * THE POSSIBILITY OF SUCH DAMAGE.
87  *
88  * =============================================================================
89  */
90 
91 
92 
93 #ifndef JSW_AVLTREE_H
94 #define JSW_AVLTREE_H
95 
96 
97 #ifdef __cplusplus
98 #include <cstddef>
99 
100 using std::size_t;
101 #include "tm.h"
102 
103 extern "C" {
104 #else
105 #include <stddef.h>
106 #include "tm.h"
107 #endif
108 
109 /* Opaque types */
110 typedef struct jsw_avltree jsw_avltree_t;
111 typedef struct jsw_avltrav jsw_avltrav_t;
112 
113 /* User-defined item handling */
114 typedef long (*cmp_f) ( const void *p1, const void *p2 );
115 #if USE_DUP_AND_REL
116 typedef void *(*dup_f) ( void *p );
117 typedef void (*rel_f) ( void *p );
118 #endif
119 
120 /* AVL tree functions */
121 #if USE_DUP_AND_REL
122 jsw_avltree_t *jsw_avlnew ( cmp_f cmp, dup_f dup, rel_f rel );
123 jsw_avltree_t *Pjsw_avlnew ( cmp_f cmp, dup_f dup, rel_f rel );
124 #else
127 #endif
130 void *jsw_avlfind ( jsw_avltree_t *tree, void *data );
131 void *Pjsw_avlfind ( jsw_avltree_t *tree, void *data );
132 long jsw_avlinsert ( jsw_avltree_t *tree, void *data );
133 long Pjsw_avlinsert ( jsw_avltree_t *tree, void *data );
134 long jsw_avlerase ( jsw_avltree_t *tree, void *data );
135 long Pjsw_avlerase ( jsw_avltree_t *tree, void *data );
136 size_t jsw_avlsize ( jsw_avltree_t *tree );
137 
138 /* Traversal functions */
139 jsw_avltrav_t *jsw_avltnew ( void );
140 void jsw_avltdelete ( jsw_avltrav_t *trav );
142 void *jsw_avltlast ( jsw_avltrav_t *trav, jsw_avltree_t *tree );
143 void *jsw_avltnext ( jsw_avltrav_t *trav );
144 void *jsw_avltprev ( jsw_avltrav_t *trav );
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif
151 
152 
153 
154 /* =============================================================================
155  *
156  * End of avltree.h
157  *
158  * =============================================================================
159  */
long jsw_avlerase(jsw_avltree_t *tree, void *data)
Definition: avltree.c:476
long(* cmp_f)(const void *p1, const void *p2)
Definition: avltree.h:114
long jsw_avlinsert(jsw_avltree_t *tree, void *data)
Definition: avltree.c:352
Definition: avltree.c:106
jsw_avltree_t * jsw_avlnew(cmp_f cmp)
Definition: avltree.c:234
void * jsw_avltprev(jsw_avltrav_t *trav)
Definition: avltree.c:747
void * jsw_avltfirst(jsw_avltrav_t *trav, jsw_avltree_t *tree)
Definition: avltree.c:732
size_t jsw_avlsize(jsw_avltree_t *tree)
Definition: avltree.c:662
void Pjsw_avldelete(jsw_avltree_t *tree)
Definition: avltree.c:305
void jsw_avldelete(jsw_avltree_t *tree)
Definition: avltree.c:277
Definition: avltree.c:116
jsw_avltree_t * tree
Definition: avltree.c:117
void * jsw_avltlast(jsw_avltrav_t *trav, jsw_avltree_t *tree)
Definition: avltree.c:737
jsw_avltrav_t * jsw_avltnew(void)
Definition: avltree.c:667
void * jsw_avlfind(jsw_avltree_t *tree, void *data)
Definition: avltree.c:336
struct @18 p
void * Pjsw_avlfind(jsw_avltree_t *tree, void *data)
jsw_avltree_t * Pjsw_avlnew(cmp_f cmp)
Definition: avltree.c:256
long Pjsw_avlinsert(jsw_avltree_t *tree, void *data)
Definition: avltree.c:414
void * jsw_avltnext(jsw_avltrav_t *trav)
Definition: avltree.c:742
Definition: data.h:80
long Pjsw_avlerase(jsw_avltree_t *tree, void *data)
Definition: avltree.c:569
void jsw_avltdelete(jsw_avltrav_t *trav)
Definition: avltree.c:672