1 | /** @file
|
---|
2 | * IPRT - AVL Trees.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2017 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___iprt_avl_h
|
---|
27 | #define ___iprt_avl_h
|
---|
28 |
|
---|
29 | #include <iprt/cdefs.h>
|
---|
30 | #include <iprt/types.h>
|
---|
31 |
|
---|
32 | RT_C_DECLS_BEGIN
|
---|
33 |
|
---|
34 | /** @defgroup grp_rt_avl RTAvl - AVL Trees
|
---|
35 | * @ingroup grp_rt
|
---|
36 | * @{
|
---|
37 | */
|
---|
38 |
|
---|
39 |
|
---|
40 | /** AVL tree of void pointers.
|
---|
41 | * @{
|
---|
42 | */
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * AVL key type
|
---|
46 | */
|
---|
47 | typedef void * AVLPVKEY;
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * AVL Core node.
|
---|
51 | */
|
---|
52 | typedef struct _AVLPVNodeCore
|
---|
53 | {
|
---|
54 | AVLPVKEY Key; /** Key value. */
|
---|
55 | struct _AVLPVNodeCore *pLeft; /** Pointer to left leaf node. */
|
---|
56 | struct _AVLPVNodeCore *pRight; /** Pointer to right leaf node. */
|
---|
57 | unsigned char uchHeight; /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
58 | } AVLPVNODECORE, *PAVLPVNODECORE, **PPAVLPVNODECORE;
|
---|
59 |
|
---|
60 | /** A tree with void pointer keys. */
|
---|
61 | typedef PAVLPVNODECORE AVLPVTREE;
|
---|
62 | /** Pointer to a tree with void pointer keys. */
|
---|
63 | typedef PPAVLPVNODECORE PAVLPVTREE;
|
---|
64 |
|
---|
65 | /** Callback function for AVLPVDoWithAll().
|
---|
66 | * @returns IPRT status codes. */
|
---|
67 | typedef DECLCALLBACK(int) AVLPVCALLBACK(PAVLPVNODECORE, void *);
|
---|
68 | /** Pointer to callback function for AVLPVDoWithAll(). */
|
---|
69 | typedef AVLPVCALLBACK *PAVLPVCALLBACK;
|
---|
70 |
|
---|
71 | /*
|
---|
72 | * Functions.
|
---|
73 | */
|
---|
74 | RTDECL(bool) RTAvlPVInsert(PAVLPVTREE ppTree, PAVLPVNODECORE pNode);
|
---|
75 | RTDECL(PAVLPVNODECORE) RTAvlPVRemove(PAVLPVTREE ppTree, AVLPVKEY Key);
|
---|
76 | RTDECL(PAVLPVNODECORE) RTAvlPVGet(PAVLPVTREE ppTree, AVLPVKEY Key);
|
---|
77 | RTDECL(PAVLPVNODECORE) RTAvlPVGetBestFit(PAVLPVTREE ppTree, AVLPVKEY Key, bool fAbove);
|
---|
78 | RTDECL(PAVLPVNODECORE) RTAvlPVRemoveBestFit(PAVLPVTREE ppTree, AVLPVKEY Key, bool fAbove);
|
---|
79 | RTDECL(int) RTAvlPVDoWithAll(PAVLPVTREE ppTree, int fFromLeft, PAVLPVCALLBACK pfnCallBack, void *pvParam);
|
---|
80 | RTDECL(int) RTAvlPVDestroy(PAVLPVTREE ppTree, PAVLPVCALLBACK pfnCallBack, void *pvParam);
|
---|
81 |
|
---|
82 | /** @} */
|
---|
83 |
|
---|
84 |
|
---|
85 | /** AVL tree of unsigned long.
|
---|
86 | * @{
|
---|
87 | */
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * AVL key type
|
---|
91 | */
|
---|
92 | typedef unsigned long AVLULKEY;
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * AVL Core node.
|
---|
96 | */
|
---|
97 | typedef struct _AVLULNodeCore
|
---|
98 | {
|
---|
99 | AVLULKEY Key; /** Key value. */
|
---|
100 | struct _AVLULNodeCore *pLeft; /** Pointer to left leaf node. */
|
---|
101 | struct _AVLULNodeCore *pRight; /** Pointer to right leaf node. */
|
---|
102 | unsigned char uchHeight; /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
103 | } AVLULNODECORE, *PAVLULNODECORE, **PPAVLULNODECORE;
|
---|
104 |
|
---|
105 |
|
---|
106 | /** Callback function for AVLULDoWithAll().
|
---|
107 | * @returns IPRT status codes. */
|
---|
108 | typedef DECLCALLBACK(int) AVLULCALLBACK(PAVLULNODECORE, void*);
|
---|
109 | /** Pointer to callback function for AVLULDoWithAll(). */
|
---|
110 | typedef AVLULCALLBACK *PAVLULCALLBACK;
|
---|
111 |
|
---|
112 |
|
---|
113 | /*
|
---|
114 | * Functions.
|
---|
115 | */
|
---|
116 | RTDECL(bool) RTAvlULInsert(PPAVLULNODECORE ppTree, PAVLULNODECORE pNode);
|
---|
117 | RTDECL(PAVLULNODECORE) RTAvlULRemove(PPAVLULNODECORE ppTree, AVLULKEY Key);
|
---|
118 | RTDECL(PAVLULNODECORE) RTAvlULGet(PPAVLULNODECORE ppTree, AVLULKEY Key);
|
---|
119 | RTDECL(PAVLULNODECORE) RTAvlULGetBestFit(PPAVLULNODECORE ppTree, AVLULKEY Key, bool fAbove);
|
---|
120 | RTDECL(PAVLULNODECORE) RTAvlULRemoveBestFit(PPAVLULNODECORE ppTree, AVLULKEY Key, bool fAbove);
|
---|
121 | RTDECL(int) RTAvlULDoWithAll(PPAVLULNODECORE ppTree, int fFromLeft, PAVLULCALLBACK pfnCallBack, void *pvParam);
|
---|
122 | RTDECL(int) RTAvlULDestroy(PPAVLULNODECORE pTree, PAVLULCALLBACK pfnCallBack, void *pvParam);
|
---|
123 |
|
---|
124 | /** @} */
|
---|
125 |
|
---|
126 |
|
---|
127 |
|
---|
128 | /** AVL tree of void pointer ranges.
|
---|
129 | * @{
|
---|
130 | */
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * AVL key type
|
---|
134 | */
|
---|
135 | typedef void *AVLRPVKEY;
|
---|
136 |
|
---|
137 | /**
|
---|
138 | * AVL Core node.
|
---|
139 | */
|
---|
140 | typedef struct AVLRPVNodeCore
|
---|
141 | {
|
---|
142 | AVLRPVKEY Key; /**< First key value in the range (inclusive). */
|
---|
143 | AVLRPVKEY KeyLast; /**< Last key value in the range (inclusive). */
|
---|
144 | struct AVLRPVNodeCore *pLeft; /**< Pointer to left leaf node. */
|
---|
145 | struct AVLRPVNodeCore *pRight; /**< Pointer to right leaf node. */
|
---|
146 | unsigned char uchHeight; /**< Height of this tree: max(height(left), height(right)) + 1 */
|
---|
147 | } AVLRPVNODECORE, *PAVLRPVNODECORE, **PPAVLRPVNODECORE;
|
---|
148 |
|
---|
149 | /** A tree with void pointer keys. */
|
---|
150 | typedef PAVLRPVNODECORE AVLRPVTREE;
|
---|
151 | /** Pointer to a tree with void pointer keys. */
|
---|
152 | typedef PPAVLRPVNODECORE PAVLRPVTREE;
|
---|
153 |
|
---|
154 | /** Callback function for AVLPVDoWithAll().
|
---|
155 | * @returns IPRT status codes. */
|
---|
156 | typedef DECLCALLBACK(int) AVLRPVCALLBACK(PAVLRPVNODECORE, void *);
|
---|
157 | /** Pointer to callback function for AVLPVDoWithAll(). */
|
---|
158 | typedef AVLRPVCALLBACK *PAVLRPVCALLBACK;
|
---|
159 |
|
---|
160 | /*
|
---|
161 | * Functions.
|
---|
162 | */
|
---|
163 | RTDECL(bool) RTAvlrPVInsert(PAVLRPVTREE ppTree, PAVLRPVNODECORE pNode);
|
---|
164 | RTDECL(PAVLRPVNODECORE) RTAvlrPVRemove(PAVLRPVTREE ppTree, AVLRPVKEY Key);
|
---|
165 | RTDECL(PAVLRPVNODECORE) RTAvlrPVGet(PAVLRPVTREE ppTree, AVLRPVKEY Key);
|
---|
166 | RTDECL(PAVLRPVNODECORE) RTAvlrPVRangeGet(PAVLRPVTREE ppTree, AVLRPVKEY Key);
|
---|
167 | RTDECL(PAVLRPVNODECORE) RTAvlrPVRangeRemove(PAVLRPVTREE ppTree, AVLRPVKEY Key);
|
---|
168 | RTDECL(PAVLRPVNODECORE) RTAvlrPVGetBestFit(PAVLRPVTREE ppTree, AVLRPVKEY Key, bool fAbove);
|
---|
169 | RTDECL(PAVLRPVNODECORE) RTAvlrPVRemoveBestFit(PAVLRPVTREE ppTree, AVLRPVKEY Key, bool fAbove);
|
---|
170 | RTDECL(int) RTAvlrPVDoWithAll(PAVLRPVTREE ppTree, int fFromLeft, PAVLRPVCALLBACK pfnCallBack, void *pvParam);
|
---|
171 | RTDECL(int) RTAvlrPVDestroy(PAVLRPVTREE ppTree, PAVLRPVCALLBACK pfnCallBack, void *pvParam);
|
---|
172 |
|
---|
173 | /** @} */
|
---|
174 |
|
---|
175 |
|
---|
176 |
|
---|
177 | /** AVL tree of uint32_t
|
---|
178 | * @{
|
---|
179 | */
|
---|
180 |
|
---|
181 | /** AVL key type. */
|
---|
182 | typedef uint32_t AVLU32KEY;
|
---|
183 |
|
---|
184 | /** AVL Core node. */
|
---|
185 | typedef struct _AVLU32NodeCore
|
---|
186 | {
|
---|
187 | struct _AVLU32NodeCore *pLeft; /**< Pointer to left leaf node. */
|
---|
188 | struct _AVLU32NodeCore *pRight; /**< Pointer to right leaf node. */
|
---|
189 | AVLU32KEY Key; /**< Key value. */
|
---|
190 | unsigned char uchHeight; /**< Height of this tree: max(height(left), height(right)) + 1 */
|
---|
191 | } AVLU32NODECORE, *PAVLU32NODECORE, **PPAVLU32NODECORE;
|
---|
192 |
|
---|
193 | /** A tree with uint32_t keys. */
|
---|
194 | typedef PAVLU32NODECORE AVLU32TREE;
|
---|
195 | /** Pointer to a tree with uint32_t keys. */
|
---|
196 | typedef PPAVLU32NODECORE PAVLU32TREE;
|
---|
197 |
|
---|
198 | /** Callback function for AVLU32DoWithAll() & AVLU32Destroy().
|
---|
199 | * @returns IPRT status codes. */
|
---|
200 | typedef DECLCALLBACK(int) AVLU32CALLBACK(PAVLU32NODECORE, void*);
|
---|
201 | /** Pointer to callback function for AVLU32DoWithAll() & AVLU32Destroy(). */
|
---|
202 | typedef AVLU32CALLBACK *PAVLU32CALLBACK;
|
---|
203 |
|
---|
204 |
|
---|
205 | /*
|
---|
206 | * Functions.
|
---|
207 | */
|
---|
208 | RTDECL(bool) RTAvlU32Insert(PAVLU32TREE pTree, PAVLU32NODECORE pNode);
|
---|
209 | RTDECL(PAVLU32NODECORE) RTAvlU32Remove(PAVLU32TREE pTree, AVLU32KEY Key);
|
---|
210 | RTDECL(PAVLU32NODECORE) RTAvlU32Get(PAVLU32TREE pTree, AVLU32KEY Key);
|
---|
211 | RTDECL(PAVLU32NODECORE) RTAvlU32GetBestFit(PAVLU32TREE pTree, AVLU32KEY Key, bool fAbove);
|
---|
212 | RTDECL(PAVLU32NODECORE) RTAvlU32RemoveBestFit(PAVLU32TREE pTree, AVLU32KEY Key, bool fAbove);
|
---|
213 | RTDECL(int) RTAvlU32DoWithAll(PAVLU32TREE pTree, int fFromLeft, PAVLU32CALLBACK pfnCallBack, void *pvParam);
|
---|
214 | RTDECL(int) RTAvlU32Destroy(PAVLU32TREE pTree, PAVLU32CALLBACK pfnCallBack, void *pvParam);
|
---|
215 |
|
---|
216 | /** @} */
|
---|
217 |
|
---|
218 | /**
|
---|
219 | * AVL uint32_t type for the relative offset pointer scheme.
|
---|
220 | */
|
---|
221 | typedef int32_t AVLOU32;
|
---|
222 |
|
---|
223 | typedef uint32_t AVLOU32KEY;
|
---|
224 |
|
---|
225 | /**
|
---|
226 | * AVL Core node.
|
---|
227 | */
|
---|
228 | typedef struct _AVLOU32NodeCore
|
---|
229 | {
|
---|
230 | /** Key value. */
|
---|
231 | AVLOU32KEY Key;
|
---|
232 | /** Offset to the left leaf node, relative to this field. */
|
---|
233 | AVLOU32 pLeft;
|
---|
234 | /** Offset to the right leaf node, relative to this field. */
|
---|
235 | AVLOU32 pRight;
|
---|
236 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
237 | unsigned char uchHeight;
|
---|
238 | } AVLOU32NODECORE, *PAVLOU32NODECORE;
|
---|
239 |
|
---|
240 | /** A offset base tree with uint32_t keys. */
|
---|
241 | typedef AVLOU32 AVLOU32TREE;
|
---|
242 | /** Pointer to an offset base tree with uint32_t keys. */
|
---|
243 | typedef AVLOU32TREE *PAVLOU32TREE;
|
---|
244 |
|
---|
245 | /** Pointer to an internal tree pointer.
|
---|
246 | * In this case it's a pointer to a relative offset. */
|
---|
247 | typedef AVLOU32TREE *PPAVLOU32NODECORE;
|
---|
248 |
|
---|
249 | /** Callback function for RTAvloU32DoWithAll().
|
---|
250 | * @returns IPRT status codes. */
|
---|
251 | typedef DECLCALLBACK(int) AVLOU32CALLBACK(PAVLOU32NODECORE pNode, void *pvUser);
|
---|
252 | /** Pointer to callback function for RTAvloU32DoWithAll(). */
|
---|
253 | typedef AVLOU32CALLBACK *PAVLOU32CALLBACK;
|
---|
254 |
|
---|
255 | RTDECL(bool) RTAvloU32Insert(PAVLOU32TREE pTree, PAVLOU32NODECORE pNode);
|
---|
256 | RTDECL(PAVLOU32NODECORE) RTAvloU32Remove(PAVLOU32TREE pTree, AVLOU32KEY Key);
|
---|
257 | RTDECL(PAVLOU32NODECORE) RTAvloU32Get(PAVLOU32TREE pTree, AVLOU32KEY Key);
|
---|
258 | RTDECL(int) RTAvloU32DoWithAll(PAVLOU32TREE pTree, int fFromLeft, PAVLOU32CALLBACK pfnCallBack, void *pvParam);
|
---|
259 | RTDECL(PAVLOU32NODECORE) RTAvloU32GetBestFit(PAVLOU32TREE ppTree, AVLOU32KEY Key, bool fAbove);
|
---|
260 | RTDECL(PAVLOU32NODECORE) RTAvloU32RemoveBestFit(PAVLOU32TREE ppTree, AVLOU32KEY Key, bool fAbove);
|
---|
261 | RTDECL(int) RTAvloU32Destroy(PAVLOU32TREE pTree, PAVLOU32CALLBACK pfnCallBack, void *pvParam);
|
---|
262 |
|
---|
263 | /** @} */
|
---|
264 |
|
---|
265 |
|
---|
266 | /** AVL tree of uint32_t, list duplicates.
|
---|
267 | * @{
|
---|
268 | */
|
---|
269 |
|
---|
270 | /** AVL key type. */
|
---|
271 | typedef uint32_t AVLLU32KEY;
|
---|
272 |
|
---|
273 | /** AVL Core node. */
|
---|
274 | typedef struct _AVLLU32NodeCore
|
---|
275 | {
|
---|
276 | AVLLU32KEY Key; /**< Key value. */
|
---|
277 | unsigned char uchHeight; /**< Height of this tree: max(height(left), height(right)) + 1 */
|
---|
278 | struct _AVLLU32NodeCore *pLeft; /**< Pointer to left leaf node. */
|
---|
279 | struct _AVLLU32NodeCore *pRight; /**< Pointer to right leaf node. */
|
---|
280 | struct _AVLLU32NodeCore *pList; /**< Pointer to next node with the same key. */
|
---|
281 | } AVLLU32NODECORE, *PAVLLU32NODECORE, **PPAVLLU32NODECORE;
|
---|
282 |
|
---|
283 | /** Callback function for RTAvllU32DoWithAll() & RTAvllU32Destroy().
|
---|
284 | * @returns IPRT status codes. */
|
---|
285 | typedef DECLCALLBACK(int) AVLLU32CALLBACK(PAVLLU32NODECORE, void*);
|
---|
286 | /** Pointer to callback function for RTAvllU32DoWithAll() & RTAvllU32Destroy(). */
|
---|
287 | typedef AVLLU32CALLBACK *PAVLLU32CALLBACK;
|
---|
288 |
|
---|
289 |
|
---|
290 | /*
|
---|
291 | * Functions.
|
---|
292 | */
|
---|
293 | RTDECL(bool) RTAvllU32Insert(PPAVLLU32NODECORE ppTree, PAVLLU32NODECORE pNode);
|
---|
294 | RTDECL(PAVLLU32NODECORE) RTAvllU32Remove(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key);
|
---|
295 | RTDECL(PAVLLU32NODECORE) RTAvllU32RemoveNode(PPAVLLU32NODECORE ppTree, PAVLLU32NODECORE pNode);
|
---|
296 | RTDECL(PAVLLU32NODECORE) RTAvllU32Get(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key);
|
---|
297 | RTDECL(PAVLLU32NODECORE) RTAvllU32GetBestFit(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key, bool fAbove);
|
---|
298 | RTDECL(PAVLLU32NODECORE) RTAvllU32RemoveBestFit(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key, bool fAbove);
|
---|
299 | RTDECL(int) RTAvllU32DoWithAll(PPAVLLU32NODECORE ppTree, int fFromLeft, PAVLLU32CALLBACK pfnCallBack, void *pvParam);
|
---|
300 | RTDECL(int) RTAvllU32Destroy(PPAVLLU32NODECORE pTree, PAVLLU32CALLBACK pfnCallBack, void *pvParam);
|
---|
301 |
|
---|
302 | /** @} */
|
---|
303 |
|
---|
304 |
|
---|
305 | /** AVL tree of uint64_t
|
---|
306 | * @{
|
---|
307 | */
|
---|
308 |
|
---|
309 | /** AVL key type. */
|
---|
310 | typedef uint64_t AVLU64KEY;
|
---|
311 |
|
---|
312 | /** AVL Core node. */
|
---|
313 | typedef struct _AVLU64NodeCore
|
---|
314 | {
|
---|
315 | struct _AVLU64NodeCore *pLeft; /**< Pointer to left leaf node. */
|
---|
316 | struct _AVLU64NodeCore *pRight; /**< Pointer to right leaf node. */
|
---|
317 | AVLU64KEY Key; /**< Key value. */
|
---|
318 | unsigned char uchHeight; /**< Height of this tree: max(height(left), height(right)) + 1 */
|
---|
319 | } AVLU64NODECORE, *PAVLU64NODECORE, **PPAVLU64NODECORE;
|
---|
320 |
|
---|
321 | /** A tree with uint64_t keys. */
|
---|
322 | typedef PAVLU64NODECORE AVLU64TREE;
|
---|
323 | /** Pointer to a tree with uint64_t keys. */
|
---|
324 | typedef PPAVLU64NODECORE PAVLU64TREE;
|
---|
325 |
|
---|
326 | /** Callback function for AVLU64DoWithAll() & AVLU64Destroy().
|
---|
327 | * @returns IPRT status codes. */
|
---|
328 | typedef DECLCALLBACK(int) AVLU64CALLBACK(PAVLU64NODECORE, void*);
|
---|
329 | /** Pointer to callback function for AVLU64DoWithAll() & AVLU64Destroy(). */
|
---|
330 | typedef AVLU64CALLBACK *PAVLU64CALLBACK;
|
---|
331 |
|
---|
332 |
|
---|
333 | /*
|
---|
334 | * Functions.
|
---|
335 | */
|
---|
336 | RTDECL(bool) RTAvlU64Insert(PAVLU64TREE pTree, PAVLU64NODECORE pNode);
|
---|
337 | RTDECL(PAVLU64NODECORE) RTAvlU64Remove(PAVLU64TREE pTree, AVLU64KEY Key);
|
---|
338 | RTDECL(PAVLU64NODECORE) RTAvlU64Get(PAVLU64TREE pTree, AVLU64KEY Key);
|
---|
339 | RTDECL(PAVLU64NODECORE) RTAvlU64GetBestFit(PAVLU64TREE pTree, AVLU64KEY Key, bool fAbove);
|
---|
340 | RTDECL(PAVLU64NODECORE) RTAvlU64RemoveBestFit(PAVLU64TREE pTree, AVLU64KEY Key, bool fAbove);
|
---|
341 | RTDECL(int) RTAvlU64DoWithAll(PAVLU64TREE pTree, int fFromLeft, PAVLU64CALLBACK pfnCallBack, void *pvParam);
|
---|
342 | RTDECL(int) RTAvlU64Destroy(PAVLU64TREE pTree, PAVLU64CALLBACK pfnCallBack, void *pvParam);
|
---|
343 |
|
---|
344 | /** @} */
|
---|
345 |
|
---|
346 |
|
---|
347 | /** AVL tree of uint64_t ranges.
|
---|
348 | * @{
|
---|
349 | */
|
---|
350 |
|
---|
351 | /**
|
---|
352 | * AVL key type
|
---|
353 | */
|
---|
354 | typedef uint64_t AVLRU64KEY;
|
---|
355 |
|
---|
356 | /**
|
---|
357 | * AVL Core node.
|
---|
358 | */
|
---|
359 | typedef struct AVLRU64NodeCore
|
---|
360 | {
|
---|
361 | AVLRU64KEY Key; /**< First key value in the range (inclusive). */
|
---|
362 | AVLRU64KEY KeyLast; /**< Last key value in the range (inclusive). */
|
---|
363 | struct AVLRU64NodeCore *pLeft; /**< Pointer to left leaf node. */
|
---|
364 | struct AVLRU64NodeCore *pRight; /**< Pointer to right leaf node. */
|
---|
365 | unsigned char uchHeight; /**< Height of this tree: max(height(left), height(right)) + 1 */
|
---|
366 | } AVLRU64NODECORE, *PAVLRU64NODECORE, **PPAVLRU64NODECORE;
|
---|
367 |
|
---|
368 | /** A tree with uint64_t keys. */
|
---|
369 | typedef PAVLRU64NODECORE AVLRU64TREE;
|
---|
370 | /** Pointer to a tree with uint64_t keys. */
|
---|
371 | typedef PPAVLRU64NODECORE PAVLRU64TREE;
|
---|
372 |
|
---|
373 | /** Callback function for AVLRU64DoWithAll().
|
---|
374 | * @returns IPRT status codes. */
|
---|
375 | typedef DECLCALLBACK(int) AVLRU64CALLBACK(PAVLRU64NODECORE, void *);
|
---|
376 | /** Pointer to callback function for AVLU64DoWithAll(). */
|
---|
377 | typedef AVLRU64CALLBACK *PAVLRU64CALLBACK;
|
---|
378 |
|
---|
379 | /*
|
---|
380 | * Functions.
|
---|
381 | */
|
---|
382 | RTDECL(bool) RTAvlrU64Insert(PAVLRU64TREE ppTree, PAVLRU64NODECORE pNode);
|
---|
383 | RTDECL(PAVLRU64NODECORE) RTAvlrU64Remove(PAVLRU64TREE ppTree, AVLRU64KEY Key);
|
---|
384 | RTDECL(PAVLRU64NODECORE) RTAvlrU64Get(PAVLRU64TREE ppTree, AVLRU64KEY Key);
|
---|
385 | RTDECL(PAVLRU64NODECORE) RTAvlrU64RangeGet(PAVLRU64TREE ppTree, AVLRU64KEY Key);
|
---|
386 | RTDECL(PAVLRU64NODECORE) RTAvlrU64RangeRemove(PAVLRU64TREE ppTree, AVLRU64KEY Key);
|
---|
387 | RTDECL(PAVLRU64NODECORE) RTAvlrU64GetBestFit(PAVLRU64TREE ppTree, AVLRU64KEY Key, bool fAbove);
|
---|
388 | RTDECL(PAVLRU64NODECORE) RTAvlrU64RemoveBestFit(PAVLRU64TREE ppTree, AVLRU64KEY Key, bool fAbove);
|
---|
389 | RTDECL(int) RTAvlrU64DoWithAll(PAVLRU64TREE ppTree, int fFromLeft, PAVLRU64CALLBACK pfnCallBack, void *pvParam);
|
---|
390 | RTDECL(int) RTAvlrU64Destroy(PAVLRU64TREE ppTree, PAVLRU64CALLBACK pfnCallBack, void *pvParam);
|
---|
391 |
|
---|
392 | /** @} */
|
---|
393 |
|
---|
394 |
|
---|
395 |
|
---|
396 | /** AVL tree of RTGCPHYSes - using relative offsets internally.
|
---|
397 | * @{
|
---|
398 | */
|
---|
399 |
|
---|
400 | /**
|
---|
401 | * AVL 'pointer' type for the relative offset pointer scheme.
|
---|
402 | */
|
---|
403 | typedef int32_t AVLOGCPHYS;
|
---|
404 |
|
---|
405 | /**
|
---|
406 | * AVL Core node.
|
---|
407 | */
|
---|
408 | typedef struct _AVLOGCPhysNodeCore
|
---|
409 | {
|
---|
410 | /** Key value. */
|
---|
411 | RTGCPHYS Key;
|
---|
412 | /** Offset to the left leaf node, relative to this field. */
|
---|
413 | AVLOGCPHYS pLeft;
|
---|
414 | /** Offset to the right leaf node, relative to this field. */
|
---|
415 | AVLOGCPHYS pRight;
|
---|
416 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
417 | unsigned char uchHeight;
|
---|
418 | /** Padding */
|
---|
419 | unsigned char Padding[7];
|
---|
420 | } AVLOGCPHYSNODECORE, *PAVLOGCPHYSNODECORE;
|
---|
421 |
|
---|
422 | /** A offset base tree with uint32_t keys. */
|
---|
423 | typedef AVLOGCPHYS AVLOGCPHYSTREE;
|
---|
424 | /** Pointer to an offset base tree with uint32_t keys. */
|
---|
425 | typedef AVLOGCPHYSTREE *PAVLOGCPHYSTREE;
|
---|
426 |
|
---|
427 | /** Pointer to an internal tree pointer.
|
---|
428 | * In this case it's a pointer to a relative offset. */
|
---|
429 | typedef AVLOGCPHYSTREE *PPAVLOGCPHYSNODECORE;
|
---|
430 |
|
---|
431 | /** Callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy().
|
---|
432 | * @returns IPRT status codes. */
|
---|
433 | typedef DECLCALLBACK(int) AVLOGCPHYSCALLBACK(PAVLOGCPHYSNODECORE pNode, void *pvUser);
|
---|
434 | /** Pointer to callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
|
---|
435 | typedef AVLOGCPHYSCALLBACK *PAVLOGCPHYSCALLBACK;
|
---|
436 |
|
---|
437 | RTDECL(bool) RTAvloGCPhysInsert(PAVLOGCPHYSTREE pTree, PAVLOGCPHYSNODECORE pNode);
|
---|
438 | RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysRemove(PAVLOGCPHYSTREE pTree, RTGCPHYS Key);
|
---|
439 | RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysGet(PAVLOGCPHYSTREE pTree, RTGCPHYS Key);
|
---|
440 | RTDECL(int) RTAvloGCPhysDoWithAll(PAVLOGCPHYSTREE pTree, int fFromLeft, PAVLOGCPHYSCALLBACK pfnCallBack, void *pvParam);
|
---|
441 | RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysGetBestFit(PAVLOGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
|
---|
442 | RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysRemoveBestFit(PAVLOGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
|
---|
443 | RTDECL(int) RTAvloGCPhysDestroy(PAVLOGCPHYSTREE pTree, PAVLOGCPHYSCALLBACK pfnCallBack, void *pvParam);
|
---|
444 |
|
---|
445 | /** @} */
|
---|
446 |
|
---|
447 |
|
---|
448 | /** AVL tree of RTGCPHYS ranges - using relative offsets internally.
|
---|
449 | * @{
|
---|
450 | */
|
---|
451 |
|
---|
452 | /**
|
---|
453 | * AVL 'pointer' type for the relative offset pointer scheme.
|
---|
454 | */
|
---|
455 | typedef int32_t AVLROGCPHYS;
|
---|
456 |
|
---|
457 | /**
|
---|
458 | * AVL Core node.
|
---|
459 | */
|
---|
460 | typedef struct _AVLROGCPhysNodeCore
|
---|
461 | {
|
---|
462 | /** First key value in the range (inclusive). */
|
---|
463 | RTGCPHYS Key;
|
---|
464 | /** Last key value in the range (inclusive). */
|
---|
465 | RTGCPHYS KeyLast;
|
---|
466 | /** Offset to the left leaf node, relative to this field. */
|
---|
467 | AVLROGCPHYS pLeft;
|
---|
468 | /** Offset to the right leaf node, relative to this field. */
|
---|
469 | AVLROGCPHYS pRight;
|
---|
470 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
471 | unsigned char uchHeight;
|
---|
472 | /** Padding */
|
---|
473 | unsigned char Padding[7];
|
---|
474 | } AVLROGCPHYSNODECORE, *PAVLROGCPHYSNODECORE;
|
---|
475 |
|
---|
476 | /** A offset base tree with uint32_t keys. */
|
---|
477 | typedef AVLROGCPHYS AVLROGCPHYSTREE;
|
---|
478 | /** Pointer to an offset base tree with uint32_t keys. */
|
---|
479 | typedef AVLROGCPHYSTREE *PAVLROGCPHYSTREE;
|
---|
480 |
|
---|
481 | /** Pointer to an internal tree pointer.
|
---|
482 | * In this case it's a pointer to a relative offset. */
|
---|
483 | typedef AVLROGCPHYSTREE *PPAVLROGCPHYSNODECORE;
|
---|
484 |
|
---|
485 | /** Callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy().
|
---|
486 | * @returns IPRT status codes. */
|
---|
487 | typedef DECLCALLBACK(int) AVLROGCPHYSCALLBACK(PAVLROGCPHYSNODECORE pNode, void *pvUser);
|
---|
488 | /** Pointer to callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
|
---|
489 | typedef AVLROGCPHYSCALLBACK *PAVLROGCPHYSCALLBACK;
|
---|
490 |
|
---|
491 | RTDECL(bool) RTAvlroGCPhysInsert(PAVLROGCPHYSTREE pTree, PAVLROGCPHYSNODECORE pNode);
|
---|
492 | RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRemove(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
|
---|
493 | RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGet(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
|
---|
494 | RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRangeGet(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
|
---|
495 | RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRangeRemove(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
|
---|
496 | RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetBestFit(PAVLROGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
|
---|
497 | RTDECL(int) RTAvlroGCPhysDoWithAll(PAVLROGCPHYSTREE pTree, int fFromLeft, PAVLROGCPHYSCALLBACK pfnCallBack, void *pvParam);
|
---|
498 | RTDECL(int) RTAvlroGCPhysDestroy(PAVLROGCPHYSTREE pTree, PAVLROGCPHYSCALLBACK pfnCallBack, void *pvParam);
|
---|
499 | RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetRoot(PAVLROGCPHYSTREE pTree);
|
---|
500 | RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetLeft(PAVLROGCPHYSNODECORE pNode);
|
---|
501 | RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetRight(PAVLROGCPHYSNODECORE pNode);
|
---|
502 |
|
---|
503 | /** @} */
|
---|
504 |
|
---|
505 |
|
---|
506 | /** AVL tree of RTGCPTRs.
|
---|
507 | * @{
|
---|
508 | */
|
---|
509 |
|
---|
510 | /**
|
---|
511 | * AVL Core node.
|
---|
512 | */
|
---|
513 | typedef struct _AVLGCPtrNodeCore
|
---|
514 | {
|
---|
515 | /** Key value. */
|
---|
516 | RTGCPTR Key;
|
---|
517 | /** Pointer to the left node. */
|
---|
518 | struct _AVLGCPtrNodeCore *pLeft;
|
---|
519 | /** Pointer to the right node. */
|
---|
520 | struct _AVLGCPtrNodeCore *pRight;
|
---|
521 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
522 | unsigned char uchHeight;
|
---|
523 | } AVLGCPTRNODECORE, *PAVLGCPTRNODECORE, **PPAVLGCPTRNODECORE;
|
---|
524 |
|
---|
525 | /** A tree of RTGCPTR keys. */
|
---|
526 | typedef PAVLGCPTRNODECORE AVLGCPTRTREE;
|
---|
527 | /** Pointer to a tree of RTGCPTR keys. */
|
---|
528 | typedef PPAVLGCPTRNODECORE PAVLGCPTRTREE;
|
---|
529 |
|
---|
530 | /** Callback function for RTAvlGCPtrDoWithAll().
|
---|
531 | * @returns IPRT status codes. */
|
---|
532 | typedef DECLCALLBACK(int) AVLGCPTRCALLBACK(PAVLGCPTRNODECORE pNode, void *pvUser);
|
---|
533 | /** Pointer to callback function for RTAvlGCPtrDoWithAll(). */
|
---|
534 | typedef AVLGCPTRCALLBACK *PAVLGCPTRCALLBACK;
|
---|
535 |
|
---|
536 | RTDECL(bool) RTAvlGCPtrInsert(PAVLGCPTRTREE pTree, PAVLGCPTRNODECORE pNode);
|
---|
537 | RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrRemove(PAVLGCPTRTREE pTree, RTGCPTR Key);
|
---|
538 | RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrGet(PAVLGCPTRTREE pTree, RTGCPTR Key);
|
---|
539 | RTDECL(int) RTAvlGCPtrDoWithAll(PAVLGCPTRTREE pTree, int fFromLeft, PAVLGCPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
540 | RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrGetBestFit(PAVLGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
|
---|
541 | RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrRemoveBestFit(PAVLGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
|
---|
542 | RTDECL(int) RTAvlGCPtrDestroy(PAVLGCPTRTREE pTree, PAVLGCPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
543 |
|
---|
544 | /** @} */
|
---|
545 |
|
---|
546 |
|
---|
547 | /** AVL tree of RTGCPTRs - using relative offsets internally.
|
---|
548 | * @{
|
---|
549 | */
|
---|
550 |
|
---|
551 | /**
|
---|
552 | * AVL 'pointer' type for the relative offset pointer scheme.
|
---|
553 | */
|
---|
554 | typedef int32_t AVLOGCPTR;
|
---|
555 |
|
---|
556 | /**
|
---|
557 | * AVL Core node.
|
---|
558 | */
|
---|
559 | typedef struct _AVLOGCPtrNodeCore
|
---|
560 | {
|
---|
561 | /** Key value. */
|
---|
562 | RTGCPTR Key;
|
---|
563 | /** Offset to the left leaf node, relative to this field. */
|
---|
564 | AVLOGCPTR pLeft;
|
---|
565 | /** Offset to the right leaf node, relative to this field. */
|
---|
566 | AVLOGCPTR pRight;
|
---|
567 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
568 | unsigned char uchHeight;
|
---|
569 | unsigned char padding[GC_ARCH_BITS == 64 ? 7 : 3];
|
---|
570 | } AVLOGCPTRNODECORE, *PAVLOGCPTRNODECORE;
|
---|
571 |
|
---|
572 | /** A offset base tree with uint32_t keys. */
|
---|
573 | typedef AVLOGCPTR AVLOGCPTRTREE;
|
---|
574 | /** Pointer to an offset base tree with uint32_t keys. */
|
---|
575 | typedef AVLOGCPTRTREE *PAVLOGCPTRTREE;
|
---|
576 |
|
---|
577 | /** Pointer to an internal tree pointer.
|
---|
578 | * In this case it's a pointer to a relative offset. */
|
---|
579 | typedef AVLOGCPTRTREE *PPAVLOGCPTRNODECORE;
|
---|
580 |
|
---|
581 | /** Callback function for RTAvloGCPtrDoWithAll().
|
---|
582 | * @returns IPRT status codes. */
|
---|
583 | typedef DECLCALLBACK(int) AVLOGCPTRCALLBACK(PAVLOGCPTRNODECORE pNode, void *pvUser);
|
---|
584 | /** Pointer to callback function for RTAvloGCPtrDoWithAll(). */
|
---|
585 | typedef AVLOGCPTRCALLBACK *PAVLOGCPTRCALLBACK;
|
---|
586 |
|
---|
587 | RTDECL(bool) RTAvloGCPtrInsert(PAVLOGCPTRTREE pTree, PAVLOGCPTRNODECORE pNode);
|
---|
588 | RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrRemove(PAVLOGCPTRTREE pTree, RTGCPTR Key);
|
---|
589 | RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrGet(PAVLOGCPTRTREE pTree, RTGCPTR Key);
|
---|
590 | RTDECL(int) RTAvloGCPtrDoWithAll(PAVLOGCPTRTREE pTree, int fFromLeft, PAVLOGCPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
591 | RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrGetBestFit(PAVLOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
|
---|
592 | RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrRemoveBestFit(PAVLOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
|
---|
593 | RTDECL(int) RTAvloGCPtrDestroy(PAVLOGCPTRTREE pTree, PAVLOGCPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
594 |
|
---|
595 | /** @} */
|
---|
596 |
|
---|
597 |
|
---|
598 | /** AVL tree of RTGCPTR ranges.
|
---|
599 | * @{
|
---|
600 | */
|
---|
601 |
|
---|
602 | /**
|
---|
603 | * AVL Core node.
|
---|
604 | */
|
---|
605 | typedef struct _AVLRGCPtrNodeCore
|
---|
606 | {
|
---|
607 | /** First key value in the range (inclusive). */
|
---|
608 | RTGCPTR Key;
|
---|
609 | /** Last key value in the range (inclusive). */
|
---|
610 | RTGCPTR KeyLast;
|
---|
611 | /** Offset to the left leaf node, relative to this field. */
|
---|
612 | struct _AVLRGCPtrNodeCore *pLeft;
|
---|
613 | /** Offset to the right leaf node, relative to this field. */
|
---|
614 | struct _AVLRGCPtrNodeCore *pRight;
|
---|
615 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
616 | unsigned char uchHeight;
|
---|
617 | } AVLRGCPTRNODECORE, *PAVLRGCPTRNODECORE;
|
---|
618 |
|
---|
619 | /** A offset base tree with RTGCPTR keys. */
|
---|
620 | typedef PAVLRGCPTRNODECORE AVLRGCPTRTREE;
|
---|
621 | /** Pointer to an offset base tree with RTGCPTR keys. */
|
---|
622 | typedef AVLRGCPTRTREE *PAVLRGCPTRTREE;
|
---|
623 |
|
---|
624 | /** Pointer to an internal tree pointer.
|
---|
625 | * In this case it's a pointer to a relative offset. */
|
---|
626 | typedef AVLRGCPTRTREE *PPAVLRGCPTRNODECORE;
|
---|
627 |
|
---|
628 | /** Callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy().
|
---|
629 | * @returns IPRT status codes. */
|
---|
630 | typedef DECLCALLBACK(int) AVLRGCPTRCALLBACK(PAVLRGCPTRNODECORE pNode, void *pvUser);
|
---|
631 | /** Pointer to callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
|
---|
632 | typedef AVLRGCPTRCALLBACK *PAVLRGCPTRCALLBACK;
|
---|
633 |
|
---|
634 | RTDECL(bool) RTAvlrGCPtrInsert( PAVLRGCPTRTREE pTree, PAVLRGCPTRNODECORE pNode);
|
---|
635 | RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrRemove( PAVLRGCPTRTREE pTree, RTGCPTR Key);
|
---|
636 | RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGet( PAVLRGCPTRTREE pTree, RTGCPTR Key);
|
---|
637 | RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetBestFit( PAVLRGCPTRTREE pTree, RTGCPTR Key, bool fAbove);
|
---|
638 | RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrRangeGet( PAVLRGCPTRTREE pTree, RTGCPTR Key);
|
---|
639 | RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrRangeRemove( PAVLRGCPTRTREE pTree, RTGCPTR Key);
|
---|
640 | RTDECL(int) RTAvlrGCPtrDoWithAll( PAVLRGCPTRTREE pTree, int fFromLeft, PAVLRGCPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
641 | RTDECL(int) RTAvlrGCPtrDestroy( PAVLRGCPTRTREE pTree, PAVLRGCPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
642 | RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetRoot( PAVLRGCPTRTREE pTree);
|
---|
643 | RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetLeft( PAVLRGCPTRNODECORE pNode);
|
---|
644 | RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetRight( PAVLRGCPTRNODECORE pNode);
|
---|
645 |
|
---|
646 | /** @} */
|
---|
647 |
|
---|
648 |
|
---|
649 | /** AVL tree of RTGCPTR ranges - using relative offsets internally.
|
---|
650 | * @{
|
---|
651 | */
|
---|
652 |
|
---|
653 | /**
|
---|
654 | * AVL 'pointer' type for the relative offset pointer scheme.
|
---|
655 | */
|
---|
656 | typedef int32_t AVLROGCPTR;
|
---|
657 |
|
---|
658 | /**
|
---|
659 | * AVL Core node.
|
---|
660 | */
|
---|
661 | typedef struct _AVLROGCPtrNodeCore
|
---|
662 | {
|
---|
663 | /** First key value in the range (inclusive). */
|
---|
664 | RTGCPTR Key;
|
---|
665 | /** Last key value in the range (inclusive). */
|
---|
666 | RTGCPTR KeyLast;
|
---|
667 | /** Offset to the left leaf node, relative to this field. */
|
---|
668 | AVLROGCPTR pLeft;
|
---|
669 | /** Offset to the right leaf node, relative to this field. */
|
---|
670 | AVLROGCPTR pRight;
|
---|
671 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
672 | unsigned char uchHeight;
|
---|
673 | unsigned char padding[GC_ARCH_BITS == 64 ? 7 : 7];
|
---|
674 | } AVLROGCPTRNODECORE, *PAVLROGCPTRNODECORE;
|
---|
675 |
|
---|
676 | /** A offset base tree with uint32_t keys. */
|
---|
677 | typedef AVLROGCPTR AVLROGCPTRTREE;
|
---|
678 | /** Pointer to an offset base tree with uint32_t keys. */
|
---|
679 | typedef AVLROGCPTRTREE *PAVLROGCPTRTREE;
|
---|
680 |
|
---|
681 | /** Pointer to an internal tree pointer.
|
---|
682 | * In this case it's a pointer to a relative offset. */
|
---|
683 | typedef AVLROGCPTRTREE *PPAVLROGCPTRNODECORE;
|
---|
684 |
|
---|
685 | /** Callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy().
|
---|
686 | * @returns IPRT status codes. */
|
---|
687 | typedef DECLCALLBACK(int) AVLROGCPTRCALLBACK(PAVLROGCPTRNODECORE pNode, void *pvUser);
|
---|
688 | /** Pointer to callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy(). */
|
---|
689 | typedef AVLROGCPTRCALLBACK *PAVLROGCPTRCALLBACK;
|
---|
690 |
|
---|
691 | RTDECL(bool) RTAvlroGCPtrInsert(PAVLROGCPTRTREE pTree, PAVLROGCPTRNODECORE pNode);
|
---|
692 | RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRemove(PAVLROGCPTRTREE pTree, RTGCPTR Key);
|
---|
693 | RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGet(PAVLROGCPTRTREE pTree, RTGCPTR Key);
|
---|
694 | RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetBestFit(PAVLROGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
|
---|
695 | RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRangeGet(PAVLROGCPTRTREE pTree, RTGCPTR Key);
|
---|
696 | RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRangeRemove(PAVLROGCPTRTREE pTree, RTGCPTR Key);
|
---|
697 | RTDECL(int) RTAvlroGCPtrDoWithAll(PAVLROGCPTRTREE pTree, int fFromLeft, PAVLROGCPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
698 | RTDECL(int) RTAvlroGCPtrDestroy(PAVLROGCPTRTREE pTree, PAVLROGCPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
699 | RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetRoot(PAVLROGCPTRTREE pTree);
|
---|
700 | RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetLeft(PAVLROGCPTRNODECORE pNode);
|
---|
701 | RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetRight(PAVLROGCPTRNODECORE pNode);
|
---|
702 |
|
---|
703 | /** @} */
|
---|
704 |
|
---|
705 |
|
---|
706 | /** AVL tree of RTGCPTR ranges (overlapping supported) - using relative offsets internally.
|
---|
707 | * @{
|
---|
708 | */
|
---|
709 |
|
---|
710 | /**
|
---|
711 | * AVL 'pointer' type for the relative offset pointer scheme.
|
---|
712 | */
|
---|
713 | typedef int32_t AVLROOGCPTR;
|
---|
714 |
|
---|
715 | /**
|
---|
716 | * AVL Core node.
|
---|
717 | */
|
---|
718 | typedef struct _AVLROOGCPtrNodeCore
|
---|
719 | {
|
---|
720 | /** First key value in the range (inclusive). */
|
---|
721 | RTGCPTR Key;
|
---|
722 | /** Last key value in the range (inclusive). */
|
---|
723 | RTGCPTR KeyLast;
|
---|
724 | /** Offset to the left leaf node, relative to this field. */
|
---|
725 | AVLROOGCPTR pLeft;
|
---|
726 | /** Offset to the right leaf node, relative to this field. */
|
---|
727 | AVLROOGCPTR pRight;
|
---|
728 | /** Pointer to the list of string with the same key. Don't touch. */
|
---|
729 | AVLROOGCPTR pList;
|
---|
730 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
731 | unsigned char uchHeight;
|
---|
732 | } AVLROOGCPTRNODECORE, *PAVLROOGCPTRNODECORE;
|
---|
733 |
|
---|
734 | /** A offset base tree with uint32_t keys. */
|
---|
735 | typedef AVLROOGCPTR AVLROOGCPTRTREE;
|
---|
736 | /** Pointer to an offset base tree with uint32_t keys. */
|
---|
737 | typedef AVLROOGCPTRTREE *PAVLROOGCPTRTREE;
|
---|
738 |
|
---|
739 | /** Pointer to an internal tree pointer.
|
---|
740 | * In this case it's a pointer to a relative offset. */
|
---|
741 | typedef AVLROOGCPTRTREE *PPAVLROOGCPTRNODECORE;
|
---|
742 |
|
---|
743 | /** Callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy().
|
---|
744 | * @returns IPRT status codes. */
|
---|
745 | typedef DECLCALLBACK(int) AVLROOGCPTRCALLBACK(PAVLROOGCPTRNODECORE pNode, void *pvUser);
|
---|
746 | /** Pointer to callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy(). */
|
---|
747 | typedef AVLROOGCPTRCALLBACK *PAVLROOGCPTRCALLBACK;
|
---|
748 |
|
---|
749 | RTDECL(bool) RTAvlrooGCPtrInsert(PAVLROOGCPTRTREE pTree, PAVLROOGCPTRNODECORE pNode);
|
---|
750 | RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRemove(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
|
---|
751 | RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGet(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
|
---|
752 | RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetBestFit(PAVLROOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
|
---|
753 | RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRangeGet(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
|
---|
754 | RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRangeRemove(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
|
---|
755 | RTDECL(int) RTAvlrooGCPtrDoWithAll(PAVLROOGCPTRTREE pTree, int fFromLeft, PAVLROOGCPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
756 | RTDECL(int) RTAvlrooGCPtrDestroy(PAVLROOGCPTRTREE pTree, PAVLROOGCPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
757 | RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetRoot(PAVLROOGCPTRTREE pTree);
|
---|
758 | RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetLeft(PAVLROOGCPTRNODECORE pNode);
|
---|
759 | RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetRight(PAVLROOGCPTRNODECORE pNode);
|
---|
760 | RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetNextEqual(PAVLROOGCPTRNODECORE pNode);
|
---|
761 |
|
---|
762 | /** @} */
|
---|
763 |
|
---|
764 |
|
---|
765 | /** AVL tree of RTUINTPTR.
|
---|
766 | * @{
|
---|
767 | */
|
---|
768 |
|
---|
769 | /**
|
---|
770 | * AVL RTUINTPTR node core.
|
---|
771 | */
|
---|
772 | typedef struct _AVLUIntPtrNodeCore
|
---|
773 | {
|
---|
774 | /** Key value. */
|
---|
775 | RTUINTPTR Key;
|
---|
776 | /** Offset to the left leaf node, relative to this field. */
|
---|
777 | struct _AVLUIntPtrNodeCore *pLeft;
|
---|
778 | /** Offset to the right leaf node, relative to this field. */
|
---|
779 | struct _AVLUIntPtrNodeCore *pRight;
|
---|
780 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
781 | unsigned char uchHeight;
|
---|
782 | } AVLUINTPTRNODECORE;
|
---|
783 | /** Pointer to a RTUINTPTR AVL node core.*/
|
---|
784 | typedef AVLUINTPTRNODECORE *PAVLUINTPTRNODECORE;
|
---|
785 |
|
---|
786 | /** A pointer based tree with RTUINTPTR keys. */
|
---|
787 | typedef PAVLUINTPTRNODECORE AVLUINTPTRTREE;
|
---|
788 | /** Pointer to an offset base tree with RTUINTPTR keys. */
|
---|
789 | typedef AVLUINTPTRTREE *PAVLUINTPTRTREE;
|
---|
790 |
|
---|
791 | /** Pointer to an internal tree pointer.
|
---|
792 | * In this case it's a pointer to a pointer. */
|
---|
793 | typedef AVLUINTPTRTREE *PPAVLUINTPTRNODECORE;
|
---|
794 |
|
---|
795 | /** Callback function for RTAvlUIntPtrDoWithAll() and RTAvlUIntPtrDestroy().
|
---|
796 | * @returns IPRT status codes. */
|
---|
797 | typedef DECLCALLBACK(int) AVLUINTPTRCALLBACK(PAVLUINTPTRNODECORE pNode, void *pvUser);
|
---|
798 | /** Pointer to callback function for RTAvlUIntPtrDoWithAll() and RTAvlUIntPtrDestroy(). */
|
---|
799 | typedef AVLUINTPTRCALLBACK *PAVLUINTPTRCALLBACK;
|
---|
800 |
|
---|
801 | RTDECL(bool) RTAvlUIntPtrInsert( PAVLUINTPTRTREE pTree, PAVLUINTPTRNODECORE pNode);
|
---|
802 | RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrRemove( PAVLUINTPTRTREE pTree, RTUINTPTR Key);
|
---|
803 | RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrGet( PAVLUINTPTRTREE pTree, RTUINTPTR Key);
|
---|
804 | RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrGetBestFit(PAVLUINTPTRTREE pTree, RTUINTPTR Key, bool fAbove);
|
---|
805 | RTDECL(int) RTAvlUIntPtrDoWithAll( PAVLUINTPTRTREE pTree, int fFromLeft, PAVLUINTPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
806 | RTDECL(int) RTAvlUIntPtrDestroy( PAVLUINTPTRTREE pTree, PAVLUINTPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
807 | RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrGetRoot( PAVLUINTPTRTREE pTree);
|
---|
808 | RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrGetLeft( PAVLUINTPTRNODECORE pNode);
|
---|
809 | RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrGetRight( PAVLUINTPTRNODECORE pNode);
|
---|
810 |
|
---|
811 | /** @} */
|
---|
812 |
|
---|
813 |
|
---|
814 | /** AVL tree of RTUINTPTR ranges.
|
---|
815 | * @{
|
---|
816 | */
|
---|
817 |
|
---|
818 | /**
|
---|
819 | * AVL RTUINTPTR range node core.
|
---|
820 | */
|
---|
821 | typedef struct _AVLRUIntPtrNodeCore
|
---|
822 | {
|
---|
823 | /** First key value in the range (inclusive). */
|
---|
824 | RTUINTPTR Key;
|
---|
825 | /** Last key value in the range (inclusive). */
|
---|
826 | RTUINTPTR KeyLast;
|
---|
827 | /** Offset to the left leaf node, relative to this field. */
|
---|
828 | struct _AVLRUIntPtrNodeCore *pLeft;
|
---|
829 | /** Offset to the right leaf node, relative to this field. */
|
---|
830 | struct _AVLRUIntPtrNodeCore *pRight;
|
---|
831 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
832 | unsigned char uchHeight;
|
---|
833 | } AVLRUINTPTRNODECORE;
|
---|
834 | /** Pointer to an AVL RTUINTPTR range node code. */
|
---|
835 | typedef AVLRUINTPTRNODECORE *PAVLRUINTPTRNODECORE;
|
---|
836 |
|
---|
837 | /** A pointer based tree with RTUINTPTR ranges. */
|
---|
838 | typedef PAVLRUINTPTRNODECORE AVLRUINTPTRTREE;
|
---|
839 | /** Pointer to a pointer based tree with RTUINTPTR ranges. */
|
---|
840 | typedef AVLRUINTPTRTREE *PAVLRUINTPTRTREE;
|
---|
841 |
|
---|
842 | /** Pointer to an internal tree pointer.
|
---|
843 | * In this case it's a pointer to a pointer. */
|
---|
844 | typedef AVLRUINTPTRTREE *PPAVLRUINTPTRNODECORE;
|
---|
845 |
|
---|
846 | /** Callback function for RTAvlrUIntPtrDoWithAll() and RTAvlrUIntPtrDestroy().
|
---|
847 | * @returns IPRT status codes. */
|
---|
848 | typedef DECLCALLBACK(int) AVLRUINTPTRCALLBACK(PAVLRUINTPTRNODECORE pNode, void *pvUser);
|
---|
849 | /** Pointer to callback function for RTAvlrUIntPtrDoWithAll() and RTAvlrUIntPtrDestroy(). */
|
---|
850 | typedef AVLRUINTPTRCALLBACK *PAVLRUINTPTRCALLBACK;
|
---|
851 |
|
---|
852 | RTDECL(bool) RTAvlrUIntPtrInsert( PAVLRUINTPTRTREE pTree, PAVLRUINTPTRNODECORE pNode);
|
---|
853 | RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrRemove( PAVLRUINTPTRTREE pTree, RTUINTPTR Key);
|
---|
854 | RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrGet( PAVLRUINTPTRTREE pTree, RTUINTPTR Key);
|
---|
855 | RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrGetBestFit( PAVLRUINTPTRTREE pTree, RTUINTPTR Key, bool fAbove);
|
---|
856 | RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrRangeGet( PAVLRUINTPTRTREE pTree, RTUINTPTR Key);
|
---|
857 | RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrRangeRemove(PAVLRUINTPTRTREE pTree, RTUINTPTR Key);
|
---|
858 | RTDECL(int) RTAvlrUIntPtrDoWithAll( PAVLRUINTPTRTREE pTree, int fFromLeft, PAVLRUINTPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
859 | RTDECL(int) RTAvlrUIntPtrDestroy( PAVLRUINTPTRTREE pTree, PAVLRUINTPTRCALLBACK pfnCallBack, void *pvParam);
|
---|
860 | RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrGetRoot( PAVLRUINTPTRTREE pTree);
|
---|
861 | RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrGetLeft( PAVLRUINTPTRNODECORE pNode);
|
---|
862 | RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrGetRight( PAVLRUINTPTRNODECORE pNode);
|
---|
863 |
|
---|
864 | /** @} */
|
---|
865 |
|
---|
866 |
|
---|
867 | /** AVL tree of RTHCPHYSes - using relative offsets internally.
|
---|
868 | * @{
|
---|
869 | */
|
---|
870 |
|
---|
871 | /**
|
---|
872 | * AVL 'pointer' type for the relative offset pointer scheme.
|
---|
873 | */
|
---|
874 | typedef int32_t AVLOHCPHYS;
|
---|
875 |
|
---|
876 | /**
|
---|
877 | * AVL Core node.
|
---|
878 | */
|
---|
879 | typedef struct _AVLOHCPhysNodeCore
|
---|
880 | {
|
---|
881 | /** Key value. */
|
---|
882 | RTHCPHYS Key;
|
---|
883 | /** Offset to the left leaf node, relative to this field. */
|
---|
884 | AVLOHCPHYS pLeft;
|
---|
885 | /** Offset to the right leaf node, relative to this field. */
|
---|
886 | AVLOHCPHYS pRight;
|
---|
887 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
888 | unsigned char uchHeight;
|
---|
889 | #if HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64
|
---|
890 | unsigned char Padding[7]; /**< Alignment padding. */
|
---|
891 | #endif
|
---|
892 | } AVLOHCPHYSNODECORE, *PAVLOHCPHYSNODECORE;
|
---|
893 |
|
---|
894 | /** A offset base tree with uint32_t keys. */
|
---|
895 | typedef AVLOHCPHYS AVLOHCPHYSTREE;
|
---|
896 | /** Pointer to an offset base tree with uint32_t keys. */
|
---|
897 | typedef AVLOHCPHYSTREE *PAVLOHCPHYSTREE;
|
---|
898 |
|
---|
899 | /** Pointer to an internal tree pointer.
|
---|
900 | * In this case it's a pointer to a relative offset. */
|
---|
901 | typedef AVLOHCPHYSTREE *PPAVLOHCPHYSNODECORE;
|
---|
902 |
|
---|
903 | /** Callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy().
|
---|
904 | * @returns IPRT status codes. */
|
---|
905 | typedef DECLCALLBACK(int) AVLOHCPHYSCALLBACK(PAVLOHCPHYSNODECORE pNode, void *pvUser);
|
---|
906 | /** Pointer to callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy(). */
|
---|
907 | typedef AVLOHCPHYSCALLBACK *PAVLOHCPHYSCALLBACK;
|
---|
908 |
|
---|
909 | RTDECL(bool) RTAvloHCPhysInsert(PAVLOHCPHYSTREE pTree, PAVLOHCPHYSNODECORE pNode);
|
---|
910 | RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysRemove(PAVLOHCPHYSTREE pTree, RTHCPHYS Key);
|
---|
911 | RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysGet(PAVLOHCPHYSTREE pTree, RTHCPHYS Key);
|
---|
912 | RTDECL(int) RTAvloHCPhysDoWithAll(PAVLOHCPHYSTREE pTree, int fFromLeft, PAVLOHCPHYSCALLBACK pfnCallBack, void *pvParam);
|
---|
913 | RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysGetBestFit(PAVLOHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
|
---|
914 | RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysRemoveBestFit(PAVLOHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
|
---|
915 | RTDECL(int) RTAvloHCPhysDestroy(PAVLOHCPHYSTREE pTree, PAVLOHCPHYSCALLBACK pfnCallBack, void *pvParam);
|
---|
916 |
|
---|
917 | /** @} */
|
---|
918 |
|
---|
919 |
|
---|
920 |
|
---|
921 | /** AVL tree of RTIOPORTs - using relative offsets internally.
|
---|
922 | * @{
|
---|
923 | */
|
---|
924 |
|
---|
925 | /**
|
---|
926 | * AVL 'pointer' type for the relative offset pointer scheme.
|
---|
927 | */
|
---|
928 | typedef int32_t AVLOIOPORTPTR;
|
---|
929 |
|
---|
930 | /**
|
---|
931 | * AVL Core node.
|
---|
932 | */
|
---|
933 | typedef struct _AVLOIOPortNodeCore
|
---|
934 | {
|
---|
935 | /** Offset to the left leaf node, relative to this field. */
|
---|
936 | AVLOIOPORTPTR pLeft;
|
---|
937 | /** Offset to the right leaf node, relative to this field. */
|
---|
938 | AVLOIOPORTPTR pRight;
|
---|
939 | /** Key value. */
|
---|
940 | RTIOPORT Key;
|
---|
941 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
942 | unsigned char uchHeight;
|
---|
943 | } AVLOIOPORTNODECORE, *PAVLOIOPORTNODECORE;
|
---|
944 |
|
---|
945 | /** A offset base tree with uint32_t keys. */
|
---|
946 | typedef AVLOIOPORTPTR AVLOIOPORTTREE;
|
---|
947 | /** Pointer to an offset base tree with uint32_t keys. */
|
---|
948 | typedef AVLOIOPORTTREE *PAVLOIOPORTTREE;
|
---|
949 |
|
---|
950 | /** Pointer to an internal tree pointer.
|
---|
951 | * In this case it's a pointer to a relative offset. */
|
---|
952 | typedef AVLOIOPORTTREE *PPAVLOIOPORTNODECORE;
|
---|
953 |
|
---|
954 | /** Callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy().
|
---|
955 | * @returns IPRT status codes. */
|
---|
956 | typedef DECLCALLBACK(int) AVLOIOPORTCALLBACK(PAVLOIOPORTNODECORE pNode, void *pvUser);
|
---|
957 | /** Pointer to callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy(). */
|
---|
958 | typedef AVLOIOPORTCALLBACK *PAVLOIOPORTCALLBACK;
|
---|
959 |
|
---|
960 | RTDECL(bool) RTAvloIOPortInsert(PAVLOIOPORTTREE pTree, PAVLOIOPORTNODECORE pNode);
|
---|
961 | RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortRemove(PAVLOIOPORTTREE pTree, RTIOPORT Key);
|
---|
962 | RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortGet(PAVLOIOPORTTREE pTree, RTIOPORT Key);
|
---|
963 | RTDECL(int) RTAvloIOPortDoWithAll(PAVLOIOPORTTREE pTree, int fFromLeft, PAVLOIOPORTCALLBACK pfnCallBack, void *pvParam);
|
---|
964 | RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortGetBestFit(PAVLOIOPORTTREE ppTree, RTIOPORT Key, bool fAbove);
|
---|
965 | RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortRemoveBestFit(PAVLOIOPORTTREE ppTree, RTIOPORT Key, bool fAbove);
|
---|
966 | RTDECL(int) RTAvloIOPortDestroy(PAVLOIOPORTTREE pTree, PAVLOIOPORTCALLBACK pfnCallBack, void *pvParam);
|
---|
967 |
|
---|
968 | /** @} */
|
---|
969 |
|
---|
970 |
|
---|
971 | /** AVL tree of RTIOPORT ranges - using relative offsets internally.
|
---|
972 | * @{
|
---|
973 | */
|
---|
974 |
|
---|
975 | /**
|
---|
976 | * AVL 'pointer' type for the relative offset pointer scheme.
|
---|
977 | */
|
---|
978 | typedef int32_t AVLROIOPORTPTR;
|
---|
979 |
|
---|
980 | /**
|
---|
981 | * AVL Core node.
|
---|
982 | */
|
---|
983 | typedef struct _AVLROIOPortNodeCore
|
---|
984 | {
|
---|
985 | /** First key value in the range (inclusive). */
|
---|
986 | RTIOPORT Key;
|
---|
987 | /** Last key value in the range (inclusive). */
|
---|
988 | RTIOPORT KeyLast;
|
---|
989 | /** Offset to the left leaf node, relative to this field. */
|
---|
990 | AVLROIOPORTPTR pLeft;
|
---|
991 | /** Offset to the right leaf node, relative to this field. */
|
---|
992 | AVLROIOPORTPTR pRight;
|
---|
993 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
994 | unsigned char uchHeight;
|
---|
995 | } AVLROIOPORTNODECORE, *PAVLROIOPORTNODECORE;
|
---|
996 |
|
---|
997 | /** A offset base tree with uint32_t keys. */
|
---|
998 | typedef AVLROIOPORTPTR AVLROIOPORTTREE;
|
---|
999 | /** Pointer to an offset base tree with uint32_t keys. */
|
---|
1000 | typedef AVLROIOPORTTREE *PAVLROIOPORTTREE;
|
---|
1001 |
|
---|
1002 | /** Pointer to an internal tree pointer.
|
---|
1003 | * In this case it's a pointer to a relative offset. */
|
---|
1004 | typedef AVLROIOPORTTREE *PPAVLROIOPORTNODECORE;
|
---|
1005 |
|
---|
1006 | /** Callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy().
|
---|
1007 | * @returns IPRT status codes. */
|
---|
1008 | typedef DECLCALLBACK(int) AVLROIOPORTCALLBACK(PAVLROIOPORTNODECORE pNode, void *pvUser);
|
---|
1009 | /** Pointer to callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy(). */
|
---|
1010 | typedef AVLROIOPORTCALLBACK *PAVLROIOPORTCALLBACK;
|
---|
1011 |
|
---|
1012 | RTDECL(bool) RTAvlroIOPortInsert(PAVLROIOPORTTREE pTree, PAVLROIOPORTNODECORE pNode);
|
---|
1013 | RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRemove(PAVLROIOPORTTREE pTree, RTIOPORT Key);
|
---|
1014 | RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortGet(PAVLROIOPORTTREE pTree, RTIOPORT Key);
|
---|
1015 | RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRangeGet(PAVLROIOPORTTREE pTree, RTIOPORT Key);
|
---|
1016 | RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRangeRemove(PAVLROIOPORTTREE pTree, RTIOPORT Key);
|
---|
1017 | RTDECL(int) RTAvlroIOPortDoWithAll(PAVLROIOPORTTREE pTree, int fFromLeft, PAVLROIOPORTCALLBACK pfnCallBack, void *pvParam);
|
---|
1018 | RTDECL(int) RTAvlroIOPortDestroy(PAVLROIOPORTTREE pTree, PAVLROIOPORTCALLBACK pfnCallBack, void *pvParam);
|
---|
1019 |
|
---|
1020 | /** @} */
|
---|
1021 |
|
---|
1022 |
|
---|
1023 | /** AVL tree of RTHCPHYSes.
|
---|
1024 | * @{
|
---|
1025 | */
|
---|
1026 |
|
---|
1027 | /**
|
---|
1028 | * AVL 'pointer' type for the relative offset pointer scheme.
|
---|
1029 | */
|
---|
1030 | typedef struct _AVLHCPhysNodeCore *AVLHCPHYSPTR;
|
---|
1031 |
|
---|
1032 | /**
|
---|
1033 | * AVL Core node.
|
---|
1034 | */
|
---|
1035 | typedef struct _AVLHCPhysNodeCore
|
---|
1036 | {
|
---|
1037 | /** Offset to the left leaf node, relative to this field. */
|
---|
1038 | AVLHCPHYSPTR pLeft;
|
---|
1039 | /** Offset to the right leaf node, relative to this field. */
|
---|
1040 | AVLHCPHYSPTR pRight;
|
---|
1041 | /** Key value. */
|
---|
1042 | RTHCPHYS Key;
|
---|
1043 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
1044 | unsigned char uchHeight;
|
---|
1045 | } AVLHCPHYSNODECORE, *PAVLHCPHYSNODECORE;
|
---|
1046 |
|
---|
1047 | /** A offset base tree with RTHCPHYS keys. */
|
---|
1048 | typedef AVLHCPHYSPTR AVLHCPHYSTREE;
|
---|
1049 | /** Pointer to an offset base tree with RTHCPHYS keys. */
|
---|
1050 | typedef AVLHCPHYSTREE *PAVLHCPHYSTREE;
|
---|
1051 |
|
---|
1052 | /** Pointer to an internal tree pointer.
|
---|
1053 | * In this case it's a pointer to a relative offset. */
|
---|
1054 | typedef AVLHCPHYSTREE *PPAVLHCPHYSNODECORE;
|
---|
1055 |
|
---|
1056 | /** Callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy().
|
---|
1057 | * @returns IPRT status codes. */
|
---|
1058 | typedef DECLCALLBACK(int) AVLHCPHYSCALLBACK(PAVLHCPHYSNODECORE pNode, void *pvUser);
|
---|
1059 | /** Pointer to callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy(). */
|
---|
1060 | typedef AVLHCPHYSCALLBACK *PAVLHCPHYSCALLBACK;
|
---|
1061 |
|
---|
1062 | RTDECL(bool) RTAvlHCPhysInsert(PAVLHCPHYSTREE pTree, PAVLHCPHYSNODECORE pNode);
|
---|
1063 | RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysRemove(PAVLHCPHYSTREE pTree, RTHCPHYS Key);
|
---|
1064 | RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysGet(PAVLHCPHYSTREE pTree, RTHCPHYS Key);
|
---|
1065 | RTDECL(int) RTAvlHCPhysDoWithAll(PAVLHCPHYSTREE pTree, int fFromLeft, PAVLHCPHYSCALLBACK pfnCallBack, void *pvParam);
|
---|
1066 | RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysGetBestFit(PAVLHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
|
---|
1067 | RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysRemoveBestFit(PAVLHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
|
---|
1068 | RTDECL(int) RTAvlHCPhysDestroy(PAVLHCPHYSTREE pTree, PAVLHCPHYSCALLBACK pfnCallBack, void *pvParam);
|
---|
1069 |
|
---|
1070 | /** @} */
|
---|
1071 |
|
---|
1072 | /** AVL tree of RTGCPHYSes.
|
---|
1073 | * @{
|
---|
1074 | */
|
---|
1075 |
|
---|
1076 | /**
|
---|
1077 | * AVL 'pointer' type for the relative offset pointer scheme.
|
---|
1078 | */
|
---|
1079 | typedef struct _AVLGCPhysNodeCore *AVLGCPHYSPTR;
|
---|
1080 |
|
---|
1081 | /**
|
---|
1082 | * AVL Core node.
|
---|
1083 | */
|
---|
1084 | typedef struct _AVLGCPhysNodeCore
|
---|
1085 | {
|
---|
1086 | /** Offset to the left leaf node, relative to this field. */
|
---|
1087 | AVLGCPHYSPTR pLeft;
|
---|
1088 | /** Offset to the right leaf node, relative to this field. */
|
---|
1089 | AVLGCPHYSPTR pRight;
|
---|
1090 | /** Key value. */
|
---|
1091 | RTGCPHYS Key;
|
---|
1092 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
1093 | unsigned char uchHeight;
|
---|
1094 | } AVLGCPHYSNODECORE, *PAVLGCPHYSNODECORE;
|
---|
1095 |
|
---|
1096 | /** A offset base tree with RTGCPHYS keys. */
|
---|
1097 | typedef AVLGCPHYSPTR AVLGCPHYSTREE;
|
---|
1098 | /** Pointer to an offset base tree with RTGCPHYS keys. */
|
---|
1099 | typedef AVLGCPHYSTREE *PAVLGCPHYSTREE;
|
---|
1100 |
|
---|
1101 | /** Pointer to an internal tree pointer.
|
---|
1102 | * In this case it's a pointer to a relative offset. */
|
---|
1103 | typedef AVLGCPHYSTREE *PPAVLGCPHYSNODECORE;
|
---|
1104 |
|
---|
1105 | /** Callback function for RTAvlGCPhysDoWithAll() and RTAvlGCPhysDestroy().
|
---|
1106 | * @returns IPRT status codes. */
|
---|
1107 | typedef DECLCALLBACK(int) AVLGCPHYSCALLBACK(PAVLGCPHYSNODECORE pNode, void *pvUser);
|
---|
1108 | /** Pointer to callback function for RTAvlGCPhysDoWithAll() and RTAvlGCPhysDestroy(). */
|
---|
1109 | typedef AVLGCPHYSCALLBACK *PAVLGCPHYSCALLBACK;
|
---|
1110 |
|
---|
1111 | RTDECL(bool) RTAvlGCPhysInsert(PAVLGCPHYSTREE pTree, PAVLGCPHYSNODECORE pNode);
|
---|
1112 | RTDECL(PAVLGCPHYSNODECORE) RTAvlGCPhysRemove(PAVLGCPHYSTREE pTree, RTGCPHYS Key);
|
---|
1113 | RTDECL(PAVLGCPHYSNODECORE) RTAvlGCPhysGet(PAVLGCPHYSTREE pTree, RTGCPHYS Key);
|
---|
1114 | RTDECL(int) RTAvlGCPhysDoWithAll(PAVLGCPHYSTREE pTree, int fFromLeft, PAVLGCPHYSCALLBACK pfnCallBack, void *pvParam);
|
---|
1115 | RTDECL(PAVLGCPHYSNODECORE) RTAvlGCPhysGetBestFit(PAVLGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
|
---|
1116 | RTDECL(PAVLGCPHYSNODECORE) RTAvlGCPhysRemoveBestFit(PAVLGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
|
---|
1117 | RTDECL(int) RTAvlGCPhysDestroy(PAVLGCPHYSTREE pTree, PAVLGCPHYSCALLBACK pfnCallBack, void *pvParam);
|
---|
1118 |
|
---|
1119 | /** @} */
|
---|
1120 |
|
---|
1121 |
|
---|
1122 | /** AVL tree of RTFOFF ranges.
|
---|
1123 | * @{
|
---|
1124 | */
|
---|
1125 |
|
---|
1126 | /**
|
---|
1127 | * AVL Core node.
|
---|
1128 | */
|
---|
1129 | typedef struct _AVLRFOFFNodeCore
|
---|
1130 | {
|
---|
1131 | /** First key value in the range (inclusive). */
|
---|
1132 | RTFOFF Key;
|
---|
1133 | /** Last key value in the range (inclusive). */
|
---|
1134 | RTFOFF KeyLast;
|
---|
1135 | /** Offset to the left leaf node, relative to this field. */
|
---|
1136 | struct _AVLRFOFFNodeCore *pLeft;
|
---|
1137 | /** Offset to the right leaf node, relative to this field. */
|
---|
1138 | struct _AVLRFOFFNodeCore *pRight;
|
---|
1139 | /** Height of this tree: max(height(left), height(right)) + 1 */
|
---|
1140 | unsigned char uchHeight;
|
---|
1141 | } AVLRFOFFNODECORE, *PAVLRFOFFNODECORE;
|
---|
1142 |
|
---|
1143 | /** A pointer based tree with RTFOFF ranges. */
|
---|
1144 | typedef PAVLRFOFFNODECORE AVLRFOFFTREE;
|
---|
1145 | /** Pointer to a pointer based tree with RTFOFF ranges. */
|
---|
1146 | typedef AVLRFOFFTREE *PAVLRFOFFTREE;
|
---|
1147 |
|
---|
1148 | /** Pointer to an internal tree pointer.
|
---|
1149 | * In this case it's a pointer to a relative offset. */
|
---|
1150 | typedef AVLRFOFFTREE *PPAVLRFOFFNODECORE;
|
---|
1151 |
|
---|
1152 | /** Callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy().
|
---|
1153 | * @returns IPRT status codes. */
|
---|
1154 | typedef DECLCALLBACK(int) AVLRFOFFCALLBACK(PAVLRFOFFNODECORE pNode, void *pvUser);
|
---|
1155 | /** Pointer to callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
|
---|
1156 | typedef AVLRFOFFCALLBACK *PAVLRFOFFCALLBACK;
|
---|
1157 |
|
---|
1158 | RTDECL(bool) RTAvlrFileOffsetInsert( PAVLRFOFFTREE pTree, PAVLRFOFFNODECORE pNode);
|
---|
1159 | RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetRemove( PAVLRFOFFTREE pTree, RTFOFF Key);
|
---|
1160 | RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetGet( PAVLRFOFFTREE pTree, RTFOFF Key);
|
---|
1161 | RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetGetBestFit( PAVLRFOFFTREE pTree, RTFOFF Key, bool fAbove);
|
---|
1162 | RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetRangeGet( PAVLRFOFFTREE pTree, RTFOFF Key);
|
---|
1163 | RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetRangeRemove( PAVLRFOFFTREE pTree, RTFOFF Key);
|
---|
1164 | RTDECL(int) RTAvlrFileOffsetDoWithAll( PAVLRFOFFTREE pTree, int fFromLeft, PAVLRFOFFCALLBACK pfnCallBack, void *pvParam);
|
---|
1165 | RTDECL(int) RTAvlrFileOffsetDestroy( PAVLRFOFFTREE pTree, PAVLRFOFFCALLBACK pfnCallBack, void *pvParam);
|
---|
1166 | RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetGetRoot( PAVLRFOFFTREE pTree);
|
---|
1167 | RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetGetLeft( PAVLRFOFFNODECORE pNode);
|
---|
1168 | RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetGetRight( PAVLRFOFFNODECORE pNode);
|
---|
1169 |
|
---|
1170 | /** @} */
|
---|
1171 |
|
---|
1172 | /** @} */
|
---|
1173 |
|
---|
1174 | RT_C_DECLS_END
|
---|
1175 |
|
---|
1176 | #endif
|
---|
1177 |
|
---|