VirtualBox

source: vbox/trunk/include/iprt/avl.h@ 65785

Last change on this file since 65785 was 65208, checked in by vboxsync, 8 years ago

Runtime/AVL: fixed headers

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette