VirtualBox

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

Last change on this file since 43902 was 40053, checked in by vboxsync, 13 years ago

IPRT: Added RTAvllU32RemoveNode.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 45.7 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 an 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) RTAvllU32RemoveNode(PPAVLLU32NODECORE ppTree, PAVLLU32NODECORE pNode);
290RTDECL(PAVLLU32NODECORE) RTAvllU32Get(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key);
291RTDECL(PAVLLU32NODECORE) RTAvllU32GetBestFit(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key, bool fAbove);
292RTDECL(PAVLLU32NODECORE) RTAvllU32RemoveBestFit(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key, bool fAbove);
293RTDECL(int) RTAvllU32DoWithAll(PPAVLLU32NODECORE ppTree, int fFromLeft, PAVLLU32CALLBACK pfnCallBack, void *pvParam);
294RTDECL(int) RTAvllU32Destroy(PPAVLLU32NODECORE pTree, PAVLLU32CALLBACK pfnCallBack, void *pvParam);
295
296/** @} */
297
298
299
300/** AVL tree of uint64_t ranges.
301 * @{
302 */
303
304/**
305 * AVL key type
306 */
307typedef uint64_t AVLRU64KEY;
308
309/**
310 * AVL Core node.
311 */
312typedef struct AVLRU64NodeCore
313{
314 AVLRU64KEY Key; /**< First key value in the range (inclusive). */
315 AVLRU64KEY KeyLast; /**< Last key value in the range (inclusive). */
316 struct AVLRU64NodeCore *pLeft; /**< Pointer to left leaf node. */
317 struct AVLRU64NodeCore *pRight; /**< Pointer to right leaf node. */
318 unsigned char uchHeight; /**< Height of this tree: max(height(left), height(right)) + 1 */
319} AVLRU64NODECORE, *PAVLRU64NODECORE, **PPAVLRU64NODECORE;
320
321/** A tree with void pointer keys. */
322typedef PAVLRU64NODECORE AVLRU64TREE;
323/** Pointer to a tree with void pointer keys. */
324typedef PPAVLRU64NODECORE PAVLRU64TREE;
325
326/** Callback function for AVLRU64DoWithAll(). */
327typedef DECLCALLBACK(int) AVLRU64CALLBACK(PAVLRU64NODECORE, void *);
328/** Pointer to callback function for AVLU64DoWithAll(). */
329typedef AVLRU64CALLBACK *PAVLRU64CALLBACK;
330
331/*
332 * Functions.
333 */
334RTDECL(bool) RTAvlrU64Insert(PAVLRU64TREE ppTree, PAVLRU64NODECORE pNode);
335RTDECL(PAVLRU64NODECORE) RTAvlrU64Remove(PAVLRU64TREE ppTree, AVLRU64KEY Key);
336RTDECL(PAVLRU64NODECORE) RTAvlrU64Get(PAVLRU64TREE ppTree, AVLRU64KEY Key);
337RTDECL(PAVLRU64NODECORE) RTAvlrU64RangeGet(PAVLRU64TREE ppTree, AVLRU64KEY Key);
338RTDECL(PAVLRU64NODECORE) RTAvlrU64RangeRemove(PAVLRU64TREE ppTree, AVLRU64KEY Key);
339RTDECL(PAVLRU64NODECORE) RTAvlrU64GetBestFit(PAVLRU64TREE ppTree, AVLRU64KEY Key, bool fAbove);
340RTDECL(PAVLRU64NODECORE) RTAvlrU64RemoveBestFit(PAVLRU64TREE ppTree, AVLRU64KEY Key, bool fAbove);
341RTDECL(int) RTAvlrU64DoWithAll(PAVLRU64TREE ppTree, int fFromLeft, PAVLRU64CALLBACK pfnCallBack, void *pvParam);
342RTDECL(int) RTAvlrU64Destroy(PAVLRU64TREE ppTree, PAVLRU64CALLBACK pfnCallBack, void *pvParam);
343
344/** @} */
345
346
347
348/** AVL tree of RTGCPHYSes - using relative offsets internally.
349 * @{
350 */
351
352/**
353 * AVL 'pointer' type for the relative offset pointer scheme.
354 */
355typedef int32_t AVLOGCPHYS;
356
357/**
358 * AVL Core node.
359 */
360typedef struct _AVLOGCPhysNodeCore
361{
362 /** Key value. */
363 RTGCPHYS Key;
364 /** Offset to the left leaf node, relative to this field. */
365 AVLOGCPHYS pLeft;
366 /** Offset to the right leaf node, relative to this field. */
367 AVLOGCPHYS pRight;
368 /** Height of this tree: max(height(left), height(right)) + 1 */
369 unsigned char uchHeight;
370 /** Padding */
371 unsigned char Padding[7];
372} AVLOGCPHYSNODECORE, *PAVLOGCPHYSNODECORE;
373
374/** A offset base tree with uint32_t keys. */
375typedef AVLOGCPHYS AVLOGCPHYSTREE;
376/** Pointer to an offset base tree with uint32_t keys. */
377typedef AVLOGCPHYSTREE *PAVLOGCPHYSTREE;
378
379/** Pointer to an internal tree pointer.
380 * In this case it's a pointer to a relative offset. */
381typedef AVLOGCPHYSTREE *PPAVLOGCPHYSNODECORE;
382
383/** Callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
384typedef DECLCALLBACK(int) AVLOGCPHYSCALLBACK(PAVLOGCPHYSNODECORE pNode, void *pvUser);
385/** Pointer to callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
386typedef AVLOGCPHYSCALLBACK *PAVLOGCPHYSCALLBACK;
387
388RTDECL(bool) RTAvloGCPhysInsert(PAVLOGCPHYSTREE pTree, PAVLOGCPHYSNODECORE pNode);
389RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysRemove(PAVLOGCPHYSTREE pTree, RTGCPHYS Key);
390RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysGet(PAVLOGCPHYSTREE pTree, RTGCPHYS Key);
391RTDECL(int) RTAvloGCPhysDoWithAll(PAVLOGCPHYSTREE pTree, int fFromLeft, PAVLOGCPHYSCALLBACK pfnCallBack, void *pvParam);
392RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysGetBestFit(PAVLOGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
393RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysRemoveBestFit(PAVLOGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
394RTDECL(int) RTAvloGCPhysDestroy(PAVLOGCPHYSTREE pTree, PAVLOGCPHYSCALLBACK pfnCallBack, void *pvParam);
395
396/** @} */
397
398
399/** AVL tree of RTGCPHYS ranges - using relative offsets internally.
400 * @{
401 */
402
403/**
404 * AVL 'pointer' type for the relative offset pointer scheme.
405 */
406typedef int32_t AVLROGCPHYS;
407
408/**
409 * AVL Core node.
410 */
411typedef struct _AVLROGCPhysNodeCore
412{
413 /** First key value in the range (inclusive). */
414 RTGCPHYS Key;
415 /** Last key value in the range (inclusive). */
416 RTGCPHYS KeyLast;
417 /** Offset to the left leaf node, relative to this field. */
418 AVLROGCPHYS pLeft;
419 /** Offset to the right leaf node, relative to this field. */
420 AVLROGCPHYS pRight;
421 /** Height of this tree: max(height(left), height(right)) + 1 */
422 unsigned char uchHeight;
423 /** Padding */
424 unsigned char Padding[7];
425} AVLROGCPHYSNODECORE, *PAVLROGCPHYSNODECORE;
426
427/** A offset base tree with uint32_t keys. */
428typedef AVLROGCPHYS AVLROGCPHYSTREE;
429/** Pointer to an offset base tree with uint32_t keys. */
430typedef AVLROGCPHYSTREE *PAVLROGCPHYSTREE;
431
432/** Pointer to an internal tree pointer.
433 * In this case it's a pointer to a relative offset. */
434typedef AVLROGCPHYSTREE *PPAVLROGCPHYSNODECORE;
435
436/** Callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
437typedef DECLCALLBACK(int) AVLROGCPHYSCALLBACK(PAVLROGCPHYSNODECORE pNode, void *pvUser);
438/** Pointer to callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
439typedef AVLROGCPHYSCALLBACK *PAVLROGCPHYSCALLBACK;
440
441RTDECL(bool) RTAvlroGCPhysInsert(PAVLROGCPHYSTREE pTree, PAVLROGCPHYSNODECORE pNode);
442RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRemove(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
443RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGet(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
444RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRangeGet(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
445RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRangeRemove(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
446RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetBestFit(PAVLROGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
447RTDECL(int) RTAvlroGCPhysDoWithAll(PAVLROGCPHYSTREE pTree, int fFromLeft, PAVLROGCPHYSCALLBACK pfnCallBack, void *pvParam);
448RTDECL(int) RTAvlroGCPhysDestroy(PAVLROGCPHYSTREE pTree, PAVLROGCPHYSCALLBACK pfnCallBack, void *pvParam);
449RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetRoot(PAVLROGCPHYSTREE pTree);
450RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetLeft(PAVLROGCPHYSNODECORE pNode);
451RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetRight(PAVLROGCPHYSNODECORE pNode);
452
453/** @} */
454
455
456/** AVL tree of RTGCPTRs.
457 * @{
458 */
459
460/**
461 * AVL Core node.
462 */
463typedef struct _AVLGCPtrNodeCore
464{
465 /** Key value. */
466 RTGCPTR Key;
467 /** Pointer to the left node. */
468 struct _AVLGCPtrNodeCore *pLeft;
469 /** Pointer to the right node. */
470 struct _AVLGCPtrNodeCore *pRight;
471 /** Height of this tree: max(height(left), height(right)) + 1 */
472 unsigned char uchHeight;
473} AVLGCPTRNODECORE, *PAVLGCPTRNODECORE, **PPAVLGCPTRNODECORE;
474
475/** A tree of RTGCPTR keys. */
476typedef PAVLGCPTRNODECORE AVLGCPTRTREE;
477/** Pointer to a tree of RTGCPTR keys. */
478typedef PPAVLGCPTRNODECORE PAVLGCPTRTREE;
479
480/** Callback function for RTAvlGCPtrDoWithAll(). */
481typedef DECLCALLBACK(int) AVLGCPTRCALLBACK(PAVLGCPTRNODECORE pNode, void *pvUser);
482/** Pointer to callback function for RTAvlGCPtrDoWithAll(). */
483typedef AVLGCPTRCALLBACK *PAVLGCPTRCALLBACK;
484
485RTDECL(bool) RTAvlGCPtrInsert(PAVLGCPTRTREE pTree, PAVLGCPTRNODECORE pNode);
486RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrRemove(PAVLGCPTRTREE pTree, RTGCPTR Key);
487RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrGet(PAVLGCPTRTREE pTree, RTGCPTR Key);
488RTDECL(int) RTAvlGCPtrDoWithAll(PAVLGCPTRTREE pTree, int fFromLeft, PAVLGCPTRCALLBACK pfnCallBack, void *pvParam);
489RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrGetBestFit(PAVLGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
490RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrRemoveBestFit(PAVLGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
491RTDECL(int) RTAvlGCPtrDestroy(PAVLGCPTRTREE pTree, PAVLGCPTRCALLBACK pfnCallBack, void *pvParam);
492
493/** @} */
494
495
496/** AVL tree of RTGCPTRs - using relative offsets internally.
497 * @{
498 */
499
500/**
501 * AVL 'pointer' type for the relative offset pointer scheme.
502 */
503typedef int32_t AVLOGCPTR;
504
505/**
506 * AVL Core node.
507 */
508typedef struct _AVLOGCPtrNodeCore
509{
510 /** Key value. */
511 RTGCPTR Key;
512 /** Offset to the left leaf node, relative to this field. */
513 AVLOGCPTR pLeft;
514 /** Offset to the right leaf node, relative to this field. */
515 AVLOGCPTR pRight;
516 /** Height of this tree: max(height(left), height(right)) + 1 */
517 unsigned char uchHeight;
518 unsigned char padding[GC_ARCH_BITS == 64 ? 7 : 3];
519} AVLOGCPTRNODECORE, *PAVLOGCPTRNODECORE;
520
521/** A offset base tree with uint32_t keys. */
522typedef AVLOGCPTR AVLOGCPTRTREE;
523/** Pointer to an offset base tree with uint32_t keys. */
524typedef AVLOGCPTRTREE *PAVLOGCPTRTREE;
525
526/** Pointer to an internal tree pointer.
527 * In this case it's a pointer to a relative offset. */
528typedef AVLOGCPTRTREE *PPAVLOGCPTRNODECORE;
529
530/** Callback function for RTAvloGCPtrDoWithAll(). */
531typedef DECLCALLBACK(int) AVLOGCPTRCALLBACK(PAVLOGCPTRNODECORE pNode, void *pvUser);
532/** Pointer to callback function for RTAvloGCPtrDoWithAll(). */
533typedef AVLOGCPTRCALLBACK *PAVLOGCPTRCALLBACK;
534
535RTDECL(bool) RTAvloGCPtrInsert(PAVLOGCPTRTREE pTree, PAVLOGCPTRNODECORE pNode);
536RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrRemove(PAVLOGCPTRTREE pTree, RTGCPTR Key);
537RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrGet(PAVLOGCPTRTREE pTree, RTGCPTR Key);
538RTDECL(int) RTAvloGCPtrDoWithAll(PAVLOGCPTRTREE pTree, int fFromLeft, PAVLOGCPTRCALLBACK pfnCallBack, void *pvParam);
539RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrGetBestFit(PAVLOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
540RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrRemoveBestFit(PAVLOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
541RTDECL(int) RTAvloGCPtrDestroy(PAVLOGCPTRTREE pTree, PAVLOGCPTRCALLBACK pfnCallBack, void *pvParam);
542
543/** @} */
544
545
546/** AVL tree of RTGCPTR ranges.
547 * @{
548 */
549
550/**
551 * AVL Core node.
552 */
553typedef struct _AVLRGCPtrNodeCore
554{
555 /** First key value in the range (inclusive). */
556 RTGCPTR Key;
557 /** Last key value in the range (inclusive). */
558 RTGCPTR KeyLast;
559 /** Offset to the left leaf node, relative to this field. */
560 struct _AVLRGCPtrNodeCore *pLeft;
561 /** Offset to the right leaf node, relative to this field. */
562 struct _AVLRGCPtrNodeCore *pRight;
563 /** Height of this tree: max(height(left), height(right)) + 1 */
564 unsigned char uchHeight;
565} AVLRGCPTRNODECORE, *PAVLRGCPTRNODECORE;
566
567/** A offset base tree with RTGCPTR keys. */
568typedef PAVLRGCPTRNODECORE AVLRGCPTRTREE;
569/** Pointer to an offset base tree with RTGCPTR keys. */
570typedef AVLRGCPTRTREE *PAVLRGCPTRTREE;
571
572/** Pointer to an internal tree pointer.
573 * In this case it's a pointer to a relative offset. */
574typedef AVLRGCPTRTREE *PPAVLRGCPTRNODECORE;
575
576/** Callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
577typedef DECLCALLBACK(int) AVLRGCPTRCALLBACK(PAVLRGCPTRNODECORE pNode, void *pvUser);
578/** Pointer to callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
579typedef AVLRGCPTRCALLBACK *PAVLRGCPTRCALLBACK;
580
581RTDECL(bool) RTAvlrGCPtrInsert( PAVLRGCPTRTREE pTree, PAVLRGCPTRNODECORE pNode);
582RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrRemove( PAVLRGCPTRTREE pTree, RTGCPTR Key);
583RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGet( PAVLRGCPTRTREE pTree, RTGCPTR Key);
584RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetBestFit( PAVLRGCPTRTREE pTree, RTGCPTR Key, bool fAbove);
585RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrRangeGet( PAVLRGCPTRTREE pTree, RTGCPTR Key);
586RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrRangeRemove( PAVLRGCPTRTREE pTree, RTGCPTR Key);
587RTDECL(int) RTAvlrGCPtrDoWithAll( PAVLRGCPTRTREE pTree, int fFromLeft, PAVLRGCPTRCALLBACK pfnCallBack, void *pvParam);
588RTDECL(int) RTAvlrGCPtrDestroy( PAVLRGCPTRTREE pTree, PAVLRGCPTRCALLBACK pfnCallBack, void *pvParam);
589RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetRoot( PAVLRGCPTRTREE pTree);
590RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetLeft( PAVLRGCPTRNODECORE pNode);
591RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetRight( PAVLRGCPTRNODECORE pNode);
592
593/** @} */
594
595
596/** AVL tree of RTGCPTR ranges - using relative offsets internally.
597 * @{
598 */
599
600/**
601 * AVL 'pointer' type for the relative offset pointer scheme.
602 */
603typedef int32_t AVLROGCPTR;
604
605/**
606 * AVL Core node.
607 */
608typedef struct _AVLROGCPtrNodeCore
609{
610 /** First key value in the range (inclusive). */
611 RTGCPTR Key;
612 /** Last key value in the range (inclusive). */
613 RTGCPTR KeyLast;
614 /** Offset to the left leaf node, relative to this field. */
615 AVLROGCPTR pLeft;
616 /** Offset to the right leaf node, relative to this field. */
617 AVLROGCPTR pRight;
618 /** Height of this tree: max(height(left), height(right)) + 1 */
619 unsigned char uchHeight;
620 unsigned char padding[GC_ARCH_BITS == 64 ? 7 : 7];
621} AVLROGCPTRNODECORE, *PAVLROGCPTRNODECORE;
622
623/** A offset base tree with uint32_t keys. */
624typedef AVLROGCPTR AVLROGCPTRTREE;
625/** Pointer to an offset base tree with uint32_t keys. */
626typedef AVLROGCPTRTREE *PAVLROGCPTRTREE;
627
628/** Pointer to an internal tree pointer.
629 * In this case it's a pointer to a relative offset. */
630typedef AVLROGCPTRTREE *PPAVLROGCPTRNODECORE;
631
632/** Callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy(). */
633typedef DECLCALLBACK(int) AVLROGCPTRCALLBACK(PAVLROGCPTRNODECORE pNode, void *pvUser);
634/** Pointer to callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy(). */
635typedef AVLROGCPTRCALLBACK *PAVLROGCPTRCALLBACK;
636
637RTDECL(bool) RTAvlroGCPtrInsert(PAVLROGCPTRTREE pTree, PAVLROGCPTRNODECORE pNode);
638RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRemove(PAVLROGCPTRTREE pTree, RTGCPTR Key);
639RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGet(PAVLROGCPTRTREE pTree, RTGCPTR Key);
640RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetBestFit(PAVLROGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
641RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRangeGet(PAVLROGCPTRTREE pTree, RTGCPTR Key);
642RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRangeRemove(PAVLROGCPTRTREE pTree, RTGCPTR Key);
643RTDECL(int) RTAvlroGCPtrDoWithAll(PAVLROGCPTRTREE pTree, int fFromLeft, PAVLROGCPTRCALLBACK pfnCallBack, void *pvParam);
644RTDECL(int) RTAvlroGCPtrDestroy(PAVLROGCPTRTREE pTree, PAVLROGCPTRCALLBACK pfnCallBack, void *pvParam);
645RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetRoot(PAVLROGCPTRTREE pTree);
646RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetLeft(PAVLROGCPTRNODECORE pNode);
647RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetRight(PAVLROGCPTRNODECORE pNode);
648
649/** @} */
650
651
652/** AVL tree of RTGCPTR ranges (overlapping supported) - using relative offsets internally.
653 * @{
654 */
655
656/**
657 * AVL 'pointer' type for the relative offset pointer scheme.
658 */
659typedef int32_t AVLROOGCPTR;
660
661/**
662 * AVL Core node.
663 */
664typedef struct _AVLROOGCPtrNodeCore
665{
666 /** First key value in the range (inclusive). */
667 RTGCPTR Key;
668 /** Last key value in the range (inclusive). */
669 RTGCPTR KeyLast;
670 /** Offset to the left leaf node, relative to this field. */
671 AVLROOGCPTR pLeft;
672 /** Offset to the right leaf node, relative to this field. */
673 AVLROOGCPTR pRight;
674 /** Pointer to the list of string with the same key. Don't touch. */
675 AVLROOGCPTR pList;
676 /** Height of this tree: max(height(left), height(right)) + 1 */
677 unsigned char uchHeight;
678} AVLROOGCPTRNODECORE, *PAVLROOGCPTRNODECORE;
679
680/** A offset base tree with uint32_t keys. */
681typedef AVLROOGCPTR AVLROOGCPTRTREE;
682/** Pointer to an offset base tree with uint32_t keys. */
683typedef AVLROOGCPTRTREE *PAVLROOGCPTRTREE;
684
685/** Pointer to an internal tree pointer.
686 * In this case it's a pointer to a relative offset. */
687typedef AVLROOGCPTRTREE *PPAVLROOGCPTRNODECORE;
688
689/** Callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy(). */
690typedef DECLCALLBACK(int) AVLROOGCPTRCALLBACK(PAVLROOGCPTRNODECORE pNode, void *pvUser);
691/** Pointer to callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy(). */
692typedef AVLROOGCPTRCALLBACK *PAVLROOGCPTRCALLBACK;
693
694RTDECL(bool) RTAvlrooGCPtrInsert(PAVLROOGCPTRTREE pTree, PAVLROOGCPTRNODECORE pNode);
695RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRemove(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
696RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGet(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
697RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetBestFit(PAVLROOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
698RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRangeGet(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
699RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRangeRemove(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
700RTDECL(int) RTAvlrooGCPtrDoWithAll(PAVLROOGCPTRTREE pTree, int fFromLeft, PAVLROOGCPTRCALLBACK pfnCallBack, void *pvParam);
701RTDECL(int) RTAvlrooGCPtrDestroy(PAVLROOGCPTRTREE pTree, PAVLROOGCPTRCALLBACK pfnCallBack, void *pvParam);
702RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetRoot(PAVLROOGCPTRTREE pTree);
703RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetLeft(PAVLROOGCPTRNODECORE pNode);
704RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetRight(PAVLROOGCPTRNODECORE pNode);
705RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetNextEqual(PAVLROOGCPTRNODECORE pNode);
706
707/** @} */
708
709
710/** AVL tree of RTUINTPTR.
711 * @{
712 */
713
714/**
715 * AVL RTUINTPTR node core.
716 */
717typedef struct _AVLUIntPtrNodeCore
718{
719 /** Key value. */
720 RTUINTPTR Key;
721 /** Offset to the left leaf node, relative to this field. */
722 struct _AVLUIntPtrNodeCore *pLeft;
723 /** Offset to the right leaf node, relative to this field. */
724 struct _AVLUIntPtrNodeCore *pRight;
725 /** Height of this tree: max(height(left), height(right)) + 1 */
726 unsigned char uchHeight;
727} AVLUINTPTRNODECORE;
728/** Pointer to a RTUINTPTR AVL node core.*/
729typedef AVLUINTPTRNODECORE *PAVLUINTPTRNODECORE;
730
731/** A pointer based tree with RTUINTPTR keys. */
732typedef PAVLUINTPTRNODECORE AVLUINTPTRTREE;
733/** Pointer to an offset base tree with RTUINTPTR keys. */
734typedef AVLUINTPTRTREE *PAVLUINTPTRTREE;
735
736/** Pointer to an internal tree pointer.
737 * In this case it's a pointer to a pointer. */
738typedef AVLUINTPTRTREE *PPAVLUINTPTRNODECORE;
739
740/** Callback function for RTAvlUIntPtrDoWithAll() and RTAvlUIntPtrDestroy(). */
741typedef DECLCALLBACK(int) AVLUINTPTRCALLBACK(PAVLUINTPTRNODECORE pNode, void *pvUser);
742/** Pointer to callback function for RTAvlUIntPtrDoWithAll() and RTAvlUIntPtrDestroy(). */
743typedef AVLUINTPTRCALLBACK *PAVLUINTPTRCALLBACK;
744
745RTDECL(bool) RTAvlUIntPtrInsert( PAVLUINTPTRTREE pTree, PAVLUINTPTRNODECORE pNode);
746RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrRemove( PAVLUINTPTRTREE pTree, RTUINTPTR Key);
747RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrGet( PAVLUINTPTRTREE pTree, RTUINTPTR Key);
748RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrGetBestFit(PAVLUINTPTRTREE pTree, RTUINTPTR Key, bool fAbove);
749RTDECL(int) RTAvlUIntPtrDoWithAll( PAVLUINTPTRTREE pTree, int fFromLeft, PAVLUINTPTRCALLBACK pfnCallBack, void *pvParam);
750RTDECL(int) RTAvlUIntPtrDestroy( PAVLUINTPTRTREE pTree, PAVLUINTPTRCALLBACK pfnCallBack, void *pvParam);
751RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrGetRoot( PAVLUINTPTRTREE pTree);
752RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrGetLeft( PAVLUINTPTRNODECORE pNode);
753RTDECL(PAVLUINTPTRNODECORE) RTAvlUIntPtrGetRight( PAVLUINTPTRNODECORE pNode);
754
755/** @} */
756
757
758/** AVL tree of RTUINTPTR ranges.
759 * @{
760 */
761
762/**
763 * AVL RTUINTPTR range node core.
764 */
765typedef struct _AVLRUIntPtrNodeCore
766{
767 /** First key value in the range (inclusive). */
768 RTUINTPTR Key;
769 /** Last key value in the range (inclusive). */
770 RTUINTPTR KeyLast;
771 /** Offset to the left leaf node, relative to this field. */
772 struct _AVLRUIntPtrNodeCore *pLeft;
773 /** Offset to the right leaf node, relative to this field. */
774 struct _AVLRUIntPtrNodeCore *pRight;
775 /** Height of this tree: max(height(left), height(right)) + 1 */
776 unsigned char uchHeight;
777} AVLRUINTPTRNODECORE;
778/** Pointer to an AVL RTUINTPTR range node code. */
779typedef AVLRUINTPTRNODECORE *PAVLRUINTPTRNODECORE;
780
781/** A pointer based tree with RTUINTPTR ranges. */
782typedef PAVLRUINTPTRNODECORE AVLRUINTPTRTREE;
783/** Pointer to a pointer based tree with RTUINTPTR ranges. */
784typedef AVLRUINTPTRTREE *PAVLRUINTPTRTREE;
785
786/** Pointer to an internal tree pointer.
787 * In this case it's a pointer to a pointer. */
788typedef AVLRUINTPTRTREE *PPAVLRUINTPTRNODECORE;
789
790/** Callback function for RTAvlrUIntPtrDoWithAll() and RTAvlrUIntPtrDestroy(). */
791typedef DECLCALLBACK(int) AVLRUINTPTRCALLBACK(PAVLRUINTPTRNODECORE pNode, void *pvUser);
792/** Pointer to callback function for RTAvlrUIntPtrDoWithAll() and RTAvlrUIntPtrDestroy(). */
793typedef AVLRUINTPTRCALLBACK *PAVLRUINTPTRCALLBACK;
794
795RTDECL(bool) RTAvlrUIntPtrInsert( PAVLRUINTPTRTREE pTree, PAVLRUINTPTRNODECORE pNode);
796RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrRemove( PAVLRUINTPTRTREE pTree, RTUINTPTR Key);
797RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrGet( PAVLRUINTPTRTREE pTree, RTUINTPTR Key);
798RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrGetBestFit( PAVLRUINTPTRTREE pTree, RTUINTPTR Key, bool fAbove);
799RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrRangeGet( PAVLRUINTPTRTREE pTree, RTUINTPTR Key);
800RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrRangeRemove(PAVLRUINTPTRTREE pTree, RTUINTPTR Key);
801RTDECL(int) RTAvlrUIntPtrDoWithAll( PAVLRUINTPTRTREE pTree, int fFromLeft, PAVLRUINTPTRCALLBACK pfnCallBack, void *pvParam);
802RTDECL(int) RTAvlrUIntPtrDestroy( PAVLRUINTPTRTREE pTree, PAVLRUINTPTRCALLBACK pfnCallBack, void *pvParam);
803RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrGetRoot( PAVLRUINTPTRTREE pTree);
804RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrGetLeft( PAVLRUINTPTRNODECORE pNode);
805RTDECL(PAVLRUINTPTRNODECORE) RTAvlrUIntPtrGetRight( PAVLRUINTPTRNODECORE pNode);
806
807/** @} */
808
809
810/** AVL tree of RTHCPHYSes - using relative offsets internally.
811 * @{
812 */
813
814/**
815 * AVL 'pointer' type for the relative offset pointer scheme.
816 */
817typedef int32_t AVLOHCPHYS;
818
819/**
820 * AVL Core node.
821 */
822typedef struct _AVLOHCPhysNodeCore
823{
824 /** Key value. */
825 RTHCPHYS Key;
826 /** Offset to the left leaf node, relative to this field. */
827 AVLOHCPHYS pLeft;
828 /** Offset to the right leaf node, relative to this field. */
829 AVLOHCPHYS pRight;
830 /** Height of this tree: max(height(left), height(right)) + 1 */
831 unsigned char uchHeight;
832#if HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64
833 unsigned char Padding[7]; /**< Alignment padding. */
834#endif
835} AVLOHCPHYSNODECORE, *PAVLOHCPHYSNODECORE;
836
837/** A offset base tree with uint32_t keys. */
838typedef AVLOHCPHYS AVLOHCPHYSTREE;
839/** Pointer to an offset base tree with uint32_t keys. */
840typedef AVLOHCPHYSTREE *PAVLOHCPHYSTREE;
841
842/** Pointer to an internal tree pointer.
843 * In this case it's a pointer to a relative offset. */
844typedef AVLOHCPHYSTREE *PPAVLOHCPHYSNODECORE;
845
846/** Callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy(). */
847typedef DECLCALLBACK(int) AVLOHCPHYSCALLBACK(PAVLOHCPHYSNODECORE pNode, void *pvUser);
848/** Pointer to callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy(). */
849typedef AVLOHCPHYSCALLBACK *PAVLOHCPHYSCALLBACK;
850
851RTDECL(bool) RTAvloHCPhysInsert(PAVLOHCPHYSTREE pTree, PAVLOHCPHYSNODECORE pNode);
852RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysRemove(PAVLOHCPHYSTREE pTree, RTHCPHYS Key);
853RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysGet(PAVLOHCPHYSTREE pTree, RTHCPHYS Key);
854RTDECL(int) RTAvloHCPhysDoWithAll(PAVLOHCPHYSTREE pTree, int fFromLeft, PAVLOHCPHYSCALLBACK pfnCallBack, void *pvParam);
855RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysGetBestFit(PAVLOHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
856RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysRemoveBestFit(PAVLOHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
857RTDECL(int) RTAvloHCPhysDestroy(PAVLOHCPHYSTREE pTree, PAVLOHCPHYSCALLBACK pfnCallBack, void *pvParam);
858
859/** @} */
860
861
862
863/** AVL tree of RTIOPORTs - using relative offsets internally.
864 * @{
865 */
866
867/**
868 * AVL 'pointer' type for the relative offset pointer scheme.
869 */
870typedef int32_t AVLOIOPORTPTR;
871
872/**
873 * AVL Core node.
874 */
875typedef struct _AVLOIOPortNodeCore
876{
877 /** Offset to the left leaf node, relative to this field. */
878 AVLOIOPORTPTR pLeft;
879 /** Offset to the right leaf node, relative to this field. */
880 AVLOIOPORTPTR pRight;
881 /** Key value. */
882 RTIOPORT Key;
883 /** Height of this tree: max(height(left), height(right)) + 1 */
884 unsigned char uchHeight;
885} AVLOIOPORTNODECORE, *PAVLOIOPORTNODECORE;
886
887/** A offset base tree with uint32_t keys. */
888typedef AVLOIOPORTPTR AVLOIOPORTTREE;
889/** Pointer to an offset base tree with uint32_t keys. */
890typedef AVLOIOPORTTREE *PAVLOIOPORTTREE;
891
892/** Pointer to an internal tree pointer.
893 * In this case it's a pointer to a relative offset. */
894typedef AVLOIOPORTTREE *PPAVLOIOPORTNODECORE;
895
896/** Callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy(). */
897typedef DECLCALLBACK(int) AVLOIOPORTCALLBACK(PAVLOIOPORTNODECORE pNode, void *pvUser);
898/** Pointer to callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy(). */
899typedef AVLOIOPORTCALLBACK *PAVLOIOPORTCALLBACK;
900
901RTDECL(bool) RTAvloIOPortInsert(PAVLOIOPORTTREE pTree, PAVLOIOPORTNODECORE pNode);
902RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortRemove(PAVLOIOPORTTREE pTree, RTIOPORT Key);
903RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortGet(PAVLOIOPORTTREE pTree, RTIOPORT Key);
904RTDECL(int) RTAvloIOPortDoWithAll(PAVLOIOPORTTREE pTree, int fFromLeft, PAVLOIOPORTCALLBACK pfnCallBack, void *pvParam);
905RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortGetBestFit(PAVLOIOPORTTREE ppTree, RTIOPORT Key, bool fAbove);
906RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortRemoveBestFit(PAVLOIOPORTTREE ppTree, RTIOPORT Key, bool fAbove);
907RTDECL(int) RTAvloIOPortDestroy(PAVLOIOPORTTREE pTree, PAVLOIOPORTCALLBACK pfnCallBack, void *pvParam);
908
909/** @} */
910
911
912/** AVL tree of RTIOPORT ranges - using relative offsets internally.
913 * @{
914 */
915
916/**
917 * AVL 'pointer' type for the relative offset pointer scheme.
918 */
919typedef int32_t AVLROIOPORTPTR;
920
921/**
922 * AVL Core node.
923 */
924typedef struct _AVLROIOPortNodeCore
925{
926 /** First key value in the range (inclusive). */
927 RTIOPORT Key;
928 /** Last key value in the range (inclusive). */
929 RTIOPORT KeyLast;
930 /** Offset to the left leaf node, relative to this field. */
931 AVLROIOPORTPTR pLeft;
932 /** Offset to the right leaf node, relative to this field. */
933 AVLROIOPORTPTR pRight;
934 /** Height of this tree: max(height(left), height(right)) + 1 */
935 unsigned char uchHeight;
936} AVLROIOPORTNODECORE, *PAVLROIOPORTNODECORE;
937
938/** A offset base tree with uint32_t keys. */
939typedef AVLROIOPORTPTR AVLROIOPORTTREE;
940/** Pointer to an offset base tree with uint32_t keys. */
941typedef AVLROIOPORTTREE *PAVLROIOPORTTREE;
942
943/** Pointer to an internal tree pointer.
944 * In this case it's a pointer to a relative offset. */
945typedef AVLROIOPORTTREE *PPAVLROIOPORTNODECORE;
946
947/** Callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy(). */
948typedef DECLCALLBACK(int) AVLROIOPORTCALLBACK(PAVLROIOPORTNODECORE pNode, void *pvUser);
949/** Pointer to callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy(). */
950typedef AVLROIOPORTCALLBACK *PAVLROIOPORTCALLBACK;
951
952RTDECL(bool) RTAvlroIOPortInsert(PAVLROIOPORTTREE pTree, PAVLROIOPORTNODECORE pNode);
953RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRemove(PAVLROIOPORTTREE pTree, RTIOPORT Key);
954RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortGet(PAVLROIOPORTTREE pTree, RTIOPORT Key);
955RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRangeGet(PAVLROIOPORTTREE pTree, RTIOPORT Key);
956RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRangeRemove(PAVLROIOPORTTREE pTree, RTIOPORT Key);
957RTDECL(int) RTAvlroIOPortDoWithAll(PAVLROIOPORTTREE pTree, int fFromLeft, PAVLROIOPORTCALLBACK pfnCallBack, void *pvParam);
958RTDECL(int) RTAvlroIOPortDestroy(PAVLROIOPORTTREE pTree, PAVLROIOPORTCALLBACK pfnCallBack, void *pvParam);
959
960/** @} */
961
962
963/** AVL tree of RTHCPHYSes.
964 * @{
965 */
966
967/**
968 * AVL 'pointer' type for the relative offset pointer scheme.
969 */
970typedef struct _AVLHCPhysNodeCore *AVLHCPHYSPTR;
971
972/**
973 * AVL Core node.
974 */
975typedef struct _AVLHCPhysNodeCore
976{
977 /** Offset to the left leaf node, relative to this field. */
978 AVLHCPHYSPTR pLeft;
979 /** Offset to the right leaf node, relative to this field. */
980 AVLHCPHYSPTR pRight;
981 /** Key value. */
982 RTHCPHYS Key;
983 /** Height of this tree: max(height(left), height(right)) + 1 */
984 unsigned char uchHeight;
985} AVLHCPHYSNODECORE, *PAVLHCPHYSNODECORE;
986
987/** A offset base tree with RTHCPHYS keys. */
988typedef AVLHCPHYSPTR AVLHCPHYSTREE;
989/** Pointer to an offset base tree with RTHCPHYS keys. */
990typedef AVLHCPHYSTREE *PAVLHCPHYSTREE;
991
992/** Pointer to an internal tree pointer.
993 * In this case it's a pointer to a relative offset. */
994typedef AVLHCPHYSTREE *PPAVLHCPHYSNODECORE;
995
996/** Callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy(). */
997typedef DECLCALLBACK(int) AVLHCPHYSCALLBACK(PAVLHCPHYSNODECORE pNode, void *pvUser);
998/** Pointer to callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy(). */
999typedef AVLHCPHYSCALLBACK *PAVLHCPHYSCALLBACK;
1000
1001RTDECL(bool) RTAvlHCPhysInsert(PAVLHCPHYSTREE pTree, PAVLHCPHYSNODECORE pNode);
1002RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysRemove(PAVLHCPHYSTREE pTree, RTHCPHYS Key);
1003RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysGet(PAVLHCPHYSTREE pTree, RTHCPHYS Key);
1004RTDECL(int) RTAvlHCPhysDoWithAll(PAVLHCPHYSTREE pTree, int fFromLeft, PAVLHCPHYSCALLBACK pfnCallBack, void *pvParam);
1005RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysGetBestFit(PAVLHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
1006RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysRemoveBestFit(PAVLHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
1007RTDECL(int) RTAvlHCPhysDestroy(PAVLHCPHYSTREE pTree, PAVLHCPHYSCALLBACK pfnCallBack, void *pvParam);
1008
1009/** @} */
1010
1011/** AVL tree of RTGCPHYSes.
1012 * @{
1013 */
1014
1015/**
1016 * AVL 'pointer' type for the relative offset pointer scheme.
1017 */
1018typedef struct _AVLGCPhysNodeCore *AVLGCPHYSPTR;
1019
1020/**
1021 * AVL Core node.
1022 */
1023typedef struct _AVLGCPhysNodeCore
1024{
1025 /** Offset to the left leaf node, relative to this field. */
1026 AVLGCPHYSPTR pLeft;
1027 /** Offset to the right leaf node, relative to this field. */
1028 AVLGCPHYSPTR pRight;
1029 /** Key value. */
1030 RTGCPHYS Key;
1031 /** Height of this tree: max(height(left), height(right)) + 1 */
1032 unsigned char uchHeight;
1033} AVLGCPHYSNODECORE, *PAVLGCPHYSNODECORE;
1034
1035/** A offset base tree with RTGCPHYS keys. */
1036typedef AVLGCPHYSPTR AVLGCPHYSTREE;
1037/** Pointer to an offset base tree with RTGCPHYS keys. */
1038typedef AVLGCPHYSTREE *PAVLGCPHYSTREE;
1039
1040/** Pointer to an internal tree pointer.
1041 * In this case it's a pointer to a relative offset. */
1042typedef AVLGCPHYSTREE *PPAVLGCPHYSNODECORE;
1043
1044/** Callback function for RTAvlGCPhysDoWithAll() and RTAvlGCPhysDestroy(). */
1045typedef DECLCALLBACK(int) AVLGCPHYSCALLBACK(PAVLGCPHYSNODECORE pNode, void *pvUser);
1046/** Pointer to callback function for RTAvlGCPhysDoWithAll() and RTAvlGCPhysDestroy(). */
1047typedef AVLGCPHYSCALLBACK *PAVLGCPHYSCALLBACK;
1048
1049RTDECL(bool) RTAvlGCPhysInsert(PAVLGCPHYSTREE pTree, PAVLGCPHYSNODECORE pNode);
1050RTDECL(PAVLGCPHYSNODECORE) RTAvlGCPhysRemove(PAVLGCPHYSTREE pTree, RTGCPHYS Key);
1051RTDECL(PAVLGCPHYSNODECORE) RTAvlGCPhysGet(PAVLGCPHYSTREE pTree, RTGCPHYS Key);
1052RTDECL(int) RTAvlGCPhysDoWithAll(PAVLGCPHYSTREE pTree, int fFromLeft, PAVLGCPHYSCALLBACK pfnCallBack, void *pvParam);
1053RTDECL(PAVLGCPHYSNODECORE) RTAvlGCPhysGetBestFit(PAVLGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
1054RTDECL(PAVLGCPHYSNODECORE) RTAvlGCPhysRemoveBestFit(PAVLGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
1055RTDECL(int) RTAvlGCPhysDestroy(PAVLGCPHYSTREE pTree, PAVLGCPHYSCALLBACK pfnCallBack, void *pvParam);
1056
1057/** @} */
1058
1059
1060/** AVL tree of RTFOFF ranges.
1061 * @{
1062 */
1063
1064/**
1065 * AVL Core node.
1066 */
1067typedef struct _AVLRFOFFNodeCore
1068{
1069 /** First key value in the range (inclusive). */
1070 RTFOFF Key;
1071 /** Last key value in the range (inclusive). */
1072 RTFOFF KeyLast;
1073 /** Offset to the left leaf node, relative to this field. */
1074 struct _AVLRFOFFNodeCore *pLeft;
1075 /** Offset to the right leaf node, relative to this field. */
1076 struct _AVLRFOFFNodeCore *pRight;
1077 /** Height of this tree: max(height(left), height(right)) + 1 */
1078 unsigned char uchHeight;
1079} AVLRFOFFNODECORE, *PAVLRFOFFNODECORE;
1080
1081/** A pointer based tree with RTFOFF ranges. */
1082typedef PAVLRFOFFNODECORE AVLRFOFFTREE;
1083/** Pointer to a pointer based tree with RTFOFF ranges. */
1084typedef AVLRFOFFTREE *PAVLRFOFFTREE;
1085
1086/** Pointer to an internal tree pointer.
1087 * In this case it's a pointer to a relative offset. */
1088typedef AVLRFOFFTREE *PPAVLRFOFFNODECORE;
1089
1090/** Callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
1091typedef DECLCALLBACK(int) AVLRFOFFCALLBACK(PAVLRFOFFNODECORE pNode, void *pvUser);
1092/** Pointer to callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
1093typedef AVLRFOFFCALLBACK *PAVLRFOFFCALLBACK;
1094
1095RTDECL(bool) RTAvlrFileOffsetInsert( PAVLRFOFFTREE pTree, PAVLRFOFFNODECORE pNode);
1096RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetRemove( PAVLRFOFFTREE pTree, RTFOFF Key);
1097RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetGet( PAVLRFOFFTREE pTree, RTFOFF Key);
1098RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetGetBestFit( PAVLRFOFFTREE pTree, RTFOFF Key, bool fAbove);
1099RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetRangeGet( PAVLRFOFFTREE pTree, RTFOFF Key);
1100RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetRangeRemove( PAVLRFOFFTREE pTree, RTFOFF Key);
1101RTDECL(int) RTAvlrFileOffsetDoWithAll( PAVLRFOFFTREE pTree, int fFromLeft, PAVLRFOFFCALLBACK pfnCallBack, void *pvParam);
1102RTDECL(int) RTAvlrFileOffsetDestroy( PAVLRFOFFTREE pTree, PAVLRFOFFCALLBACK pfnCallBack, void *pvParam);
1103RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetGetRoot( PAVLRFOFFTREE pTree);
1104RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetGetLeft( PAVLRFOFFNODECORE pNode);
1105RTDECL(PAVLRFOFFNODECORE) RTAvlrFileOffsetGetRight( PAVLRFOFFNODECORE pNode);
1106
1107/** @} */
1108
1109/** @} */
1110
1111RT_C_DECLS_END
1112
1113#endif
1114
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