tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rbtree.h
Go to the documentation of this file.
1 /* =============================================================================
2  *
3  * rbtree.h
4  * -- Red-black balanced binary search tree
5  *
6  * =============================================================================
7  *
8  * Copyright (C) Sun Microsystems Inc., 2006. All Rights Reserved.
9  * Authors: Dave Dice, Nir Shavit, Ori Shalev.
10  *
11  * STM: Transactional Locking for Disjoint Access Parallelism
12  *
13  * Transactional Locking II,
14  * Dave Dice, Ori Shalev, Nir Shavit
15  * DISC 2006, Sept 2006, Stockholm, Sweden.
16  *
17  * =============================================================================
18  *
19  * Modified by Chi Cao Minh
20  *
21  * =============================================================================
22  *
23  * For the license of bayes/sort.h and bayes/sort.c, please see the header
24  * of the files.
25  *
26  * ------------------------------------------------------------------------
27  *
28  * For the license of kmeans, please see kmeans/LICENSE.kmeans
29  *
30  * ------------------------------------------------------------------------
31  *
32  * For the license of ssca2, please see ssca2/COPYRIGHT
33  *
34  * ------------------------------------------------------------------------
35  *
36  * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
37  * header of the files.
38  *
39  * ------------------------------------------------------------------------
40  *
41  * For the license of lib/rbtree.h and lib/rbtree.c, please see
42  * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
43  *
44  * ------------------------------------------------------------------------
45  *
46  * Unless otherwise noted, the following license applies to STAMP files:
47  *
48  * Copyright (c) 2007, Stanford University
49  * All rights reserved.
50  *
51  * Redistribution and use in source and binary forms, with or without
52  * modification, are permitted provided that the following conditions are
53  * met:
54  *
55  * * Redistributions of source code must retain the above copyright
56  * notice, this list of conditions and the following disclaimer.
57  *
58  * * Redistributions in binary form must reproduce the above copyright
59  * notice, this list of conditions and the following disclaimer in
60  * the documentation and/or other materials provided with the
61  * distribution.
62  *
63  * * Neither the name of Stanford University nor the names of its
64  * contributors may be used to endorse or promote products derived
65  * from this software without specific prior written permission.
66  *
67  * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
68  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
69  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
70  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
71  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
72  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
73  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
74  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
75  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
76  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
77  * THE POSSIBILITY OF SUCH DAMAGE.
78  *
79  * =============================================================================
80  */
81 
82 
83 #ifndef RBTREE_H
84 #define RBTREE_H 1
85 
86 
87 #include "tm.h"
88 #include "types.h"
89 #include "lehigh.h"
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
95 
96 typedef struct rbtree rbtree_t;
97 
98 
99 /* =============================================================================
100  * rbtree_verify
101  * =============================================================================
102  */
103 long
104 rbtree_verify (rbtree_t* s, long verbose);
105 
106 
107 /* =============================================================================
108  * rbtree_alloc
109  * =============================================================================
110  */
111 rbtree_t*
113 
114 
115 /* =============================================================================
116  * TMrbtree_alloc
117  * =============================================================================
118  */
119 rbtree_t*
121 
122 
123 /* =============================================================================
124  * rbtree_free
125  * =============================================================================
126  */
127 void
128 rbtree_free (rbtree_t* r);
129 
130 
131 /* =============================================================================
132  * TMrbtree_free
133  * =============================================================================
134  */
135 void
137 
138 
139 /* =============================================================================
140  * rbtree_insert
141  * -- Returns TRUE on success
142  * =============================================================================
143  */
144 bool_t
145 rbtree_insert (rbtree_t* r, void* key, void* val);
146 
147 
148 /* =============================================================================
149  * TMrbtree_insert
150  * -- Returns TRUE on success
151  * =============================================================================
152  */
154 bool_t
155 TMrbtree_insert (TM_ARGDECL rbtree_t* r, void* key, void* val);
156 
157 
158 /* =============================================================================
159  * rbtree_delete
160  * =============================================================================
161  */
162 bool_t
163 rbtree_delete (rbtree_t* r, void* key);
164 
165 
166 /* =============================================================================
167  * TMrbtree_delete
168  * =============================================================================
169  */
171 bool_t
172 TMrbtree_delete (TM_ARGDECL rbtree_t* r, void* key);
173 
174 
175 /* =============================================================================
176  * rbtree_update
177  * -- Return FALSE if had to insert node first
178  * =============================================================================
179  */
180 bool_t
181 rbtree_update (rbtree_t* r, void* key, void* val);
182 
183 
184 /* =============================================================================
185  * TMrbtree_update
186  * -- Return FALSE if had to insert node first
187  * =============================================================================
188  */
190 bool_t
191 TMrbtree_update (TM_ARGDECL rbtree_t* r, void* key, void* val);
192 
193 
194 /* =============================================================================
195  * rbtree_get
196  * =============================================================================
197  */
198 void*
199 rbtree_get (rbtree_t* r, void* key);
200 
201 
202 /* =============================================================================
203  * TMrbtree_get
204  * =============================================================================
205  */
207 void*
208 TMrbtree_get (TM_ARGDECL rbtree_t* r, void* key);
209 
210 
211 /* =============================================================================
212  * rbtree_contains
213  * =============================================================================
214  */
215 bool_t
216 rbtree_contains (rbtree_t* r, void* key);
217 
218 
219 /* =============================================================================
220  * TMrbtree_contains
221  * =============================================================================
222  */
224 bool_t
225 TMrbtree_contains (TM_ARGDECL rbtree_t* r, void* key);
226 
227 
228 #define TMRBTREE_ALLOC(cmp) TMrbtree_alloc(TM_ARG_ALONE, cmp)
229 #define TMRBTREE_FREE(r) TMrbtree_free(TM_ARG r)
230 #define TMRBTREE_INSERT(r, k, v) TMrbtree_insert(TM_ARG r, (void*)(k), (void*)(v))
231 #define TMRBTREE_DELETE(r, k) TMrbtree_delete(TM_ARG r, (void*)(k))
232 #define TMRBTREE_UPDATE(r, k, v) TMrbtree_update(TM_ARG r, (void*)(k), (void*)(v))
233 #define TMRBTREE_GET(r, k) TMrbtree_get(TM_ARG r, (void*)(k))
234 #define TMRBTREE_CONTAINS(r, k) TMrbtree_contains(TM_ARG r, (void*)(k))
235 
236 
237 #ifdef __cplusplus
238 }
239 #endif
240 
241 
242 
243 #endif /* RBTREE_H */
244 
245 
246 
247 /* =============================================================================
248  *
249  * End of rbtree.h
250  *
251  * =============================================================================
252  */
#define TM_CALLABLE
Definition: cxxtm.hpp:32
TM_CALLABLE bool_t TMrbtree_contains(TM_ARGDECL rbtree_t *r, void *key)
Definition: rbtree.c:1564
bool verbose
Definition: mesh.cpp:44
rbtree_t * rbtree_alloc(comparator_t *compare)
Definition: rbtree.c:1276
bool_t rbtree_insert(rbtree_t *r, void *key, void *val)
Definition: rbtree.c:1411
int bool_t
Definition: portable_defns.h:32
#define TM_ARGDECL
Definition: tm.h:532
comparator_t * compare
Definition: rbtree.c:104
void rbtree_free(rbtree_t *r)
Definition: rbtree.c:1362
Definition: rbtree.c:102
TM_CALLABLE bool_t TMrbtree_insert(TM_ARGDECL rbtree_t *r, void *key, void *val)
Definition: rbtree.c:1428
bool_t rbtree_update(rbtree_t *r, void *key, void *val)
Definition: rbtree.c:1485
bool_t rbtree_contains(rbtree_t *r, void *key)
Definition: rbtree.c:1552
TM_CALLABLE bool_t TMrbtree_delete(TM_ARGDECL rbtree_t *r, void *key)
Definition: rbtree.c:1465
Definition: lehigh.h:29
long rbtree_verify(rbtree_t *s, long verbose)
Definition: rbtree.c:1197
rbtree_t * TMrbtree_alloc(TM_ARGDECL comparator_t *compare)
Definition: rbtree.c:1292
void * rbtree_get(rbtree_t *r, void *key)
Definition: rbtree.c:1522
void TMrbtree_free(TM_ARGDECL rbtree_t *r)
Definition: rbtree.c:1374
bool_t rbtree_delete(rbtree_t *r, void *key)
Definition: rbtree.c:1445
TM_CALLABLE void * TMrbtree_get(TM_ARGDECL rbtree_t *r, void *key)
Definition: rbtree.c:1537
TM_CALLABLE bool_t TMrbtree_update(TM_ARGDECL rbtree_t *r, void *key, void *val)
Definition: rbtree.c:1504