VirtualBox

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

Last change on this file since 33973 was 33268, checked in by vboxsync, 14 years ago

IPRT: Added an AVL tree taking void * ranges.

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