VirtualBox

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

Last change on this file since 8006 was 7620, checked in by vboxsync, 16 years ago

RTGCPHYS is now 64 bits

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 30.6 KB
Line 
1/** @file
2 * innotek Portable Runtime - 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
32__BEGIN_DECLS
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);
120
121/** @} */
122
123
124
125/** AVL tree of uint32_t
126 * @{
127 */
128
129/** AVL key type. */
130typedef uint32_t AVLU32KEY;
131
132/** AVL Core node. */
133typedef struct _AVLU32NodeCore
134{
135 AVLU32KEY Key; /**< Key value. */
136 struct _AVLU32NodeCore *pLeft; /**< Pointer to left leaf node. */
137 struct _AVLU32NodeCore *pRight; /**< Pointer to right leaf node. */
138 unsigned char uchHeight; /**< Height of this tree: max(height(left), height(right)) + 1 */
139} AVLU32NODECORE, *PAVLU32NODECORE, **PPAVLU32NODECORE;
140
141/** Callback function for AVLU32DoWithAll() & AVLU32Destroy(). */
142typedef DECLCALLBACK(int) AVLU32CALLBACK(PAVLU32NODECORE, void*);
143/** Pointer to callback function for AVLU32DoWithAll() & AVLU32Destroy(). */
144typedef AVLU32CALLBACK *PAVLU32CALLBACK;
145
146
147/*
148 * Functions.
149 */
150RTDECL(bool) RTAvlU32Insert(PPAVLU32NODECORE ppTree, PAVLU32NODECORE pNode);
151RTDECL(PAVLU32NODECORE) RTAvlU32Remove(PPAVLU32NODECORE ppTree, AVLU32KEY Key);
152RTDECL(PAVLU32NODECORE) RTAvlU32Get(PPAVLU32NODECORE ppTree, AVLU32KEY Key);
153RTDECL(PAVLU32NODECORE) RTAvlU32GetBestFit(PPAVLU32NODECORE ppTree, AVLU32KEY Key, bool fAbove);
154RTDECL(PAVLU32NODECORE) RTAvlU32RemoveBestFit(PPAVLU32NODECORE ppTree, AVLU32KEY Key, bool fAbove);
155RTDECL(int) RTAvlU32DoWithAll(PPAVLU32NODECORE ppTree, int fFromLeft, PAVLU32CALLBACK pfnCallBack, void *pvParam);
156RTDECL(int) RTAvlU32Destroy(PPAVLU32NODECORE pTree, PAVLU32CALLBACK pfnCallBack, void *pvParam);
157
158/** @} */
159
160
161
162/** AVL tree of uint32_t, list duplicates.
163 * @{
164 */
165
166/** AVL key type. */
167typedef uint32_t AVLLU32KEY;
168
169/** AVL Core node. */
170typedef struct _AVLLU32NodeCore
171{
172 AVLLU32KEY Key; /**< Key value. */
173 unsigned char uchHeight; /**< Height of this tree: max(height(left), height(right)) + 1 */
174 struct _AVLLU32NodeCore *pLeft; /**< Pointer to left leaf node. */
175 struct _AVLLU32NodeCore *pRight; /**< Pointer to right leaf node. */
176 struct _AVLLU32NodeCore *pList; /**< Pointer to next node with the same key. */
177} AVLLU32NODECORE, *PAVLLU32NODECORE, **PPAVLLU32NODECORE;
178
179/** Callback function for RTAvllU32DoWithAll() & RTAvllU32Destroy(). */
180typedef DECLCALLBACK(int) AVLLU32CALLBACK(PAVLLU32NODECORE, void*);
181/** Pointer to callback function for RTAvllU32DoWithAll() & RTAvllU32Destroy(). */
182typedef AVLLU32CALLBACK *PAVLLU32CALLBACK;
183
184
185/*
186 * Functions.
187 */
188RTDECL(bool) RTAvllU32Insert(PPAVLLU32NODECORE ppTree, PAVLLU32NODECORE pNode);
189RTDECL(PAVLLU32NODECORE) RTAvllU32Remove(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key);
190RTDECL(PAVLLU32NODECORE) RTAvllU32Get(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key);
191RTDECL(PAVLLU32NODECORE) RTAvllU32GetBestFit(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key, bool fAbove);
192RTDECL(PAVLLU32NODECORE) RTAvllU32RemoveBestFit(PPAVLLU32NODECORE ppTree, AVLLU32KEY Key, bool fAbove);
193RTDECL(int) RTAvllU32DoWithAll(PPAVLLU32NODECORE ppTree, int fFromLeft, PAVLLU32CALLBACK pfnCallBack, void *pvParam);
194RTDECL(int) RTAvllU32Destroy(PPAVLLU32NODECORE pTree, PAVLLU32CALLBACK pfnCallBack, void *pvParam);
195
196/** @} */
197
198
199
200/** AVL tree of RTGCPHYSes - using relative offsets internally.
201 * @{
202 */
203
204/**
205 * AVL 'pointer' type for the relative offset pointer scheme.
206 */
207typedef int32_t AVLOGCPHYS;
208
209/**
210 * AVL Core node.
211 */
212typedef struct _AVLOGCPhysNodeCore
213{
214 /** Key value. */
215 RTGCPHYS Key;
216 /** Offset to the left leaf node, relative to this field. */
217 AVLOGCPHYS pLeft;
218 /** Offset to the right leaf node, relative to this field. */
219 AVLOGCPHYS pRight;
220 /** Height of this tree: max(height(left), height(right)) + 1 */
221 unsigned char uchHeight;
222 /** Padding */
223 unsigned char Padding[7];
224} AVLOGCPHYSNODECORE, *PAVLOGCPHYSNODECORE;
225
226/** A offset base tree with uint32_t keys. */
227typedef AVLOGCPHYS AVLOGCPHYSTREE;
228/** Pointer to a offset base tree with uint32_t keys. */
229typedef AVLOGCPHYSTREE *PAVLOGCPHYSTREE;
230
231/** Pointer to an internal tree pointer.
232 * In this case it's a pointer to a relative offset. */
233typedef AVLOGCPHYSTREE *PPAVLOGCPHYSNODECORE;
234
235/** Callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
236typedef DECLCALLBACK(int) AVLOGCPHYSCALLBACK(PAVLOGCPHYSNODECORE pNode, void *pvUser);
237/** Pointer to callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
238typedef AVLOGCPHYSCALLBACK *PAVLOGCPHYSCALLBACK;
239
240RTDECL(bool) RTAvloGCPhysInsert(PAVLOGCPHYSTREE pTree, PAVLOGCPHYSNODECORE pNode);
241RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysRemove(PAVLOGCPHYSTREE pTree, RTGCPHYS Key);
242RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysGet(PAVLOGCPHYSTREE pTree, RTGCPHYS Key);
243RTDECL(int) RTAvloGCPhysDoWithAll(PAVLOGCPHYSTREE pTree, int fFromLeft, PAVLOGCPHYSCALLBACK pfnCallBack, void *pvParam);
244RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysGetBestFit(PAVLOGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
245RTDECL(PAVLOGCPHYSNODECORE) RTAvloGCPhysRemoveBestFit(PAVLOGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
246RTDECL(int) RTAvloGCPhysDestroy(PAVLOGCPHYSTREE pTree, PAVLOGCPHYSCALLBACK pfnCallBack, void *pvParam);
247
248/** @} */
249
250
251/** AVL tree of RTGCPHYS ranges - using relative offsets internally.
252 * @{
253 */
254
255/**
256 * AVL 'pointer' type for the relative offset pointer scheme.
257 */
258typedef int32_t AVLROGCPHYS;
259
260/**
261 * AVL Core node.
262 */
263typedef struct _AVLROGCPhysNodeCore
264{
265 /** First key value in the range (inclusive). */
266 RTGCPHYS Key;
267 /** Last key value in the range (inclusive). */
268 RTGCPHYS KeyLast;
269 /** Offset to the left leaf node, relative to this field. */
270 AVLROGCPHYS pLeft;
271 /** Offset to the right leaf node, relative to this field. */
272 AVLROGCPHYS pRight;
273 /** Height of this tree: max(height(left), height(right)) + 1 */
274 unsigned char uchHeight;
275 /** Padding */
276 unsigned char Padding[7];
277} AVLROGCPHYSNODECORE, *PAVLROGCPHYSNODECORE;
278
279/** A offset base tree with uint32_t keys. */
280typedef AVLROGCPHYS AVLROGCPHYSTREE;
281/** Pointer to a offset base tree with uint32_t keys. */
282typedef AVLROGCPHYSTREE *PAVLROGCPHYSTREE;
283
284/** Pointer to an internal tree pointer.
285 * In this case it's a pointer to a relative offset. */
286typedef AVLROGCPHYSTREE *PPAVLROGCPHYSNODECORE;
287
288/** Callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
289typedef DECLCALLBACK(int) AVLROGCPHYSCALLBACK(PAVLROGCPHYSNODECORE pNode, void *pvUser);
290/** Pointer to callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
291typedef AVLROGCPHYSCALLBACK *PAVLROGCPHYSCALLBACK;
292
293RTDECL(bool) RTAvlroGCPhysInsert(PAVLROGCPHYSTREE pTree, PAVLROGCPHYSNODECORE pNode);
294RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRemove(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
295RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGet(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
296RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRangeGet(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
297RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysRangeRemove(PAVLROGCPHYSTREE pTree, RTGCPHYS Key);
298RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetBestFit(PAVLROGCPHYSTREE ppTree, RTGCPHYS Key, bool fAbove);
299RTDECL(int) RTAvlroGCPhysDoWithAll(PAVLROGCPHYSTREE pTree, int fFromLeft, PAVLROGCPHYSCALLBACK pfnCallBack, void *pvParam);
300RTDECL(int) RTAvlroGCPhysDestroy(PAVLROGCPHYSTREE pTree, PAVLROGCPHYSCALLBACK pfnCallBack, void *pvParam);
301RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetRoot(PAVLROGCPHYSTREE pTree);
302RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetLeft(PAVLROGCPHYSNODECORE pNode);
303RTDECL(PAVLROGCPHYSNODECORE) RTAvlroGCPhysGetRight(PAVLROGCPHYSNODECORE pNode);
304
305/** @} */
306
307
308/** AVL tree of RTGCPTRs.
309 * @{
310 */
311
312/**
313 * AVL Core node.
314 */
315typedef struct _AVLGCPtrNodeCore
316{
317 /** Key value. */
318 RTGCPTR Key;
319 /** Pointer to the left node. */
320 struct _AVLGCPtrNodeCore *pLeft;
321 /** Pointer to the right node. */
322 struct _AVLGCPtrNodeCore *pRight;
323 /** Height of this tree: max(height(left), height(right)) + 1 */
324 unsigned char uchHeight;
325} AVLGCPTRNODECORE, *PAVLGCPTRNODECORE, **PPAVLGCPTRNODECORE;
326
327/** A tree of RTGCPTR keys. */
328typedef PAVLGCPTRNODECORE AVLGCPTRTREE;
329/** Pointer to a tree of RTGCPTR keys. */
330typedef PPAVLGCPTRNODECORE PAVLGCPTRTREE;
331
332/** Callback function for RTAvlGCPtrDoWithAll(). */
333typedef DECLCALLBACK(int) AVLGCPTRCALLBACK(PAVLGCPTRNODECORE pNode, void *pvUser);
334/** Pointer to callback function for RTAvlGCPtrDoWithAll(). */
335typedef AVLGCPTRCALLBACK *PAVLGCPTRCALLBACK;
336
337RTDECL(bool) RTAvlGCPtrInsert(PAVLGCPTRTREE pTree, PAVLGCPTRNODECORE pNode);
338RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrRemove(PAVLGCPTRTREE pTree, RTGCPTR Key);
339RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrGet(PAVLGCPTRTREE pTree, RTGCPTR Key);
340RTDECL(int) RTAvlGCPtrDoWithAll(PAVLGCPTRTREE pTree, int fFromLeft, PAVLGCPTRCALLBACK pfnCallBack, void *pvParam);
341RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrGetBestFit(PAVLGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
342RTDECL(PAVLGCPTRNODECORE) RTAvlGCPtrRemoveBestFit(PAVLGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
343RTDECL(int) RTAvlGCPtrDestroy(PAVLGCPTRTREE pTree, PAVLGCPTRCALLBACK pfnCallBack, void *pvParam);
344
345/** @} */
346
347
348/** AVL tree of RTGCPTRs - using relative offsets internally.
349 * @{
350 */
351
352/**
353 * AVL 'pointer' type for the relative offset pointer scheme.
354 */
355typedef int32_t AVLOGCPTR;
356
357/**
358 * AVL Core node.
359 */
360typedef struct _AVLOGCPtrNodeCore
361{
362 /** Key value. */
363 RTGCPTR Key;
364 /** Offset to the left leaf node, relative to this field. */
365 AVLOGCPTR pLeft;
366 /** Offset to the right leaf node, relative to this field. */
367 AVLOGCPTR pRight;
368 /** Height of this tree: max(height(left), height(right)) + 1 */
369 unsigned char uchHeight;
370} AVLOGCPTRNODECORE, *PAVLOGCPTRNODECORE;
371
372/** A offset base tree with uint32_t keys. */
373typedef AVLOGCPTR AVLOGCPTRTREE;
374/** Pointer to a offset base tree with uint32_t keys. */
375typedef AVLOGCPTRTREE *PAVLOGCPTRTREE;
376
377/** Pointer to an internal tree pointer.
378 * In this case it's a pointer to a relative offset. */
379typedef AVLOGCPTRTREE *PPAVLOGCPTRNODECORE;
380
381/** Callback function for RTAvloGCPtrDoWithAll(). */
382typedef DECLCALLBACK(int) AVLOGCPTRCALLBACK(PAVLOGCPTRNODECORE pNode, void *pvUser);
383/** Pointer to callback function for RTAvloGCPtrDoWithAll(). */
384typedef AVLOGCPTRCALLBACK *PAVLOGCPTRCALLBACK;
385
386RTDECL(bool) RTAvloGCPtrInsert(PAVLOGCPTRTREE pTree, PAVLOGCPTRNODECORE pNode);
387RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrRemove(PAVLOGCPTRTREE pTree, RTGCPTR Key);
388RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrGet(PAVLOGCPTRTREE pTree, RTGCPTR Key);
389RTDECL(int) RTAvloGCPtrDoWithAll(PAVLOGCPTRTREE pTree, int fFromLeft, PAVLOGCPTRCALLBACK pfnCallBack, void *pvParam);
390RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrGetBestFit(PAVLOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
391RTDECL(PAVLOGCPTRNODECORE) RTAvloGCPtrRemoveBestFit(PAVLOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
392RTDECL(int) RTAvloGCPtrDestroy(PAVLOGCPTRTREE pTree, PAVLOGCPTRCALLBACK pfnCallBack, void *pvParam);
393
394/** @} */
395
396
397/** AVL tree of RTGCPTR ranges.
398 * @{
399 */
400
401/**
402 * AVL Core node.
403 */
404typedef struct _AVLRGCPtrNodeCore
405{
406 /** First key value in the range (inclusive). */
407 RTGCPTR Key;
408 /** Last key value in the range (inclusive). */
409 RTGCPTR KeyLast;
410 /** Offset to the left leaf node, relative to this field. */
411 struct _AVLRGCPtrNodeCore *pLeft;
412 /** Offset to the right leaf node, relative to this field. */
413 struct _AVLRGCPtrNodeCore *pRight;
414 /** Height of this tree: max(height(left), height(right)) + 1 */
415 unsigned char uchHeight;
416} AVLRGCPTRNODECORE, *PAVLRGCPTRNODECORE;
417
418/** A offset base tree with RTGCPTR keys. */
419typedef PAVLRGCPTRNODECORE AVLRGCPTRTREE;
420/** Pointer to a offset base tree with RTGCPTR keys. */
421typedef AVLRGCPTRTREE *PAVLRGCPTRTREE;
422
423/** Pointer to an internal tree pointer.
424 * In this case it's a pointer to a relative offset. */
425typedef AVLRGCPTRTREE *PPAVLRGCPTRNODECORE;
426
427/** Callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
428typedef DECLCALLBACK(int) AVLRGCPTRCALLBACK(PAVLRGCPTRNODECORE pNode, void *pvUser);
429/** Pointer to callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
430typedef AVLRGCPTRCALLBACK *PAVLRGCPTRCALLBACK;
431
432RTDECL(bool) RTAvlrGCPtrInsert( PAVLRGCPTRTREE pTree, PAVLRGCPTRNODECORE pNode);
433RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrRemove( PAVLRGCPTRTREE pTree, RTGCPTR Key);
434RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGet( PAVLRGCPTRTREE pTree, RTGCPTR Key);
435RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetBestFit( PAVLRGCPTRTREE pTree, RTGCPTR Key, bool fAbove);
436RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrRangeGet( PAVLRGCPTRTREE pTree, RTGCPTR Key);
437RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrRangeRemove( PAVLRGCPTRTREE pTree, RTGCPTR Key);
438RTDECL(int) RTAvlrGCPtrDoWithAll( PAVLRGCPTRTREE pTree, int fFromLeft, PAVLRGCPTRCALLBACK pfnCallBack, void *pvParam);
439RTDECL(int) RTAvlrGCPtrDestroy( PAVLRGCPTRTREE pTree, PAVLRGCPTRCALLBACK pfnCallBack, void *pvParam);
440RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetRoot( PAVLRGCPTRTREE pTree);
441RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetLeft( PAVLRGCPTRNODECORE pNode);
442RTDECL(PAVLRGCPTRNODECORE) RTAvlrGCPtrGetRight( PAVLRGCPTRNODECORE pNode);
443
444/** @} */
445
446
447/** AVL tree of RTGCPTR ranges - using relative offsets internally.
448 * @{
449 */
450
451/**
452 * AVL 'pointer' type for the relative offset pointer scheme.
453 */
454typedef int32_t AVLROGCPTR;
455
456/**
457 * AVL Core node.
458 */
459typedef struct _AVLROGCPtrNodeCore
460{
461 /** First key value in the range (inclusive). */
462 RTGCPTR Key;
463 /** Last key value in the range (inclusive). */
464 RTGCPTR KeyLast;
465 /** Offset to the left leaf node, relative to this field. */
466 AVLROGCPTR pLeft;
467 /** Offset to the right leaf node, relative to this field. */
468 AVLROGCPTR pRight;
469 /** Height of this tree: max(height(left), height(right)) + 1 */
470 unsigned char uchHeight;
471} AVLROGCPTRNODECORE, *PAVLROGCPTRNODECORE;
472
473/** A offset base tree with uint32_t keys. */
474typedef AVLROGCPTR AVLROGCPTRTREE;
475/** Pointer to a offset base tree with uint32_t keys. */
476typedef AVLROGCPTRTREE *PAVLROGCPTRTREE;
477
478/** Pointer to an internal tree pointer.
479 * In this case it's a pointer to a relative offset. */
480typedef AVLROGCPTRTREE *PPAVLROGCPTRNODECORE;
481
482/** Callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy(). */
483typedef DECLCALLBACK(int) AVLROGCPTRCALLBACK(PAVLROGCPTRNODECORE pNode, void *pvUser);
484/** Pointer to callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy(). */
485typedef AVLROGCPTRCALLBACK *PAVLROGCPTRCALLBACK;
486
487RTDECL(bool) RTAvlroGCPtrInsert(PAVLROGCPTRTREE pTree, PAVLROGCPTRNODECORE pNode);
488RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRemove(PAVLROGCPTRTREE pTree, RTGCPTR Key);
489RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGet(PAVLROGCPTRTREE pTree, RTGCPTR Key);
490RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetBestFit(PAVLROGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
491RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRangeGet(PAVLROGCPTRTREE pTree, RTGCPTR Key);
492RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrRangeRemove(PAVLROGCPTRTREE pTree, RTGCPTR Key);
493RTDECL(int) RTAvlroGCPtrDoWithAll(PAVLROGCPTRTREE pTree, int fFromLeft, PAVLROGCPTRCALLBACK pfnCallBack, void *pvParam);
494RTDECL(int) RTAvlroGCPtrDestroy(PAVLROGCPTRTREE pTree, PAVLROGCPTRCALLBACK pfnCallBack, void *pvParam);
495RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetRoot(PAVLROGCPTRTREE pTree);
496RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetLeft(PAVLROGCPTRNODECORE pNode);
497RTDECL(PAVLROGCPTRNODECORE) RTAvlroGCPtrGetRight(PAVLROGCPTRNODECORE pNode);
498
499/** @} */
500
501
502/** AVL tree of RTGCPTR ranges (overlapping supported) - using relative offsets internally.
503 * @{
504 */
505
506/**
507 * AVL 'pointer' type for the relative offset pointer scheme.
508 */
509typedef int32_t AVLROOGCPTR;
510
511/**
512 * AVL Core node.
513 */
514typedef struct _AVLROOGCPtrNodeCore
515{
516 /** First key value in the range (inclusive). */
517 RTGCPTR Key;
518 /** Last key value in the range (inclusive). */
519 RTGCPTR KeyLast;
520 /** Offset to the left leaf node, relative to this field. */
521 AVLROOGCPTR pLeft;
522 /** Offset to the right leaf node, relative to this field. */
523 AVLROOGCPTR pRight;
524 /** Pointer to the list of string with the same key. Don't touch. */
525 AVLROOGCPTR pList;
526 /** Height of this tree: max(height(left), height(right)) + 1 */
527 unsigned char uchHeight;
528} AVLROOGCPTRNODECORE, *PAVLROOGCPTRNODECORE;
529
530/** A offset base tree with uint32_t keys. */
531typedef AVLROOGCPTR AVLROOGCPTRTREE;
532/** Pointer to a offset base tree with uint32_t keys. */
533typedef AVLROOGCPTRTREE *PAVLROOGCPTRTREE;
534
535/** Pointer to an internal tree pointer.
536 * In this case it's a pointer to a relative offset. */
537typedef AVLROOGCPTRTREE *PPAVLROOGCPTRNODECORE;
538
539/** Callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy(). */
540typedef DECLCALLBACK(int) AVLROOGCPTRCALLBACK(PAVLROOGCPTRNODECORE pNode, void *pvUser);
541/** Pointer to callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy(). */
542typedef AVLROOGCPTRCALLBACK *PAVLROOGCPTRCALLBACK;
543
544RTDECL(bool) RTAvlrooGCPtrInsert(PAVLROOGCPTRTREE pTree, PAVLROOGCPTRNODECORE pNode);
545RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRemove(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
546RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGet(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
547RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetBestFit(PAVLROOGCPTRTREE ppTree, RTGCPTR Key, bool fAbove);
548RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRangeGet(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
549RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrRangeRemove(PAVLROOGCPTRTREE pTree, RTGCPTR Key);
550RTDECL(int) RTAvlrooGCPtrDoWithAll(PAVLROOGCPTRTREE pTree, int fFromLeft, PAVLROOGCPTRCALLBACK pfnCallBack, void *pvParam);
551RTDECL(int) RTAvlrooGCPtrDestroy(PAVLROOGCPTRTREE pTree, PAVLROOGCPTRCALLBACK pfnCallBack, void *pvParam);
552RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetRoot(PAVLROOGCPTRTREE pTree);
553RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetLeft(PAVLROOGCPTRNODECORE pNode);
554RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetRight(PAVLROOGCPTRNODECORE pNode);
555RTDECL(PAVLROOGCPTRNODECORE) RTAvlrooGCPtrGetNextEqual(PAVLROOGCPTRNODECORE pNode);
556
557/** @} */
558
559
560/** AVL tree of RTHCPHYSes - using relative offsets internally.
561 * @{
562 */
563
564/**
565 * AVL 'pointer' type for the relative offset pointer scheme.
566 */
567typedef int32_t AVLOHCPHYS;
568
569/**
570 * AVL Core node.
571 */
572typedef struct _AVLOHCPhysNodeCore
573{
574 /** Key value. */
575 RTHCPHYS Key;
576 /** Offset to the left leaf node, relative to this field. */
577 AVLOHCPHYS pLeft;
578 /** Offset to the right leaf node, relative to this field. */
579 AVLOHCPHYS pRight;
580 /** Height of this tree: max(height(left), height(right)) + 1 */
581 unsigned char uchHeight;
582#if HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64
583 unsigned char Padding[7]; /**< Alignment padding. */
584#endif
585} AVLOHCPHYSNODECORE, *PAVLOHCPHYSNODECORE;
586
587/** A offset base tree with uint32_t keys. */
588typedef AVLOHCPHYS AVLOHCPHYSTREE;
589/** Pointer to a offset base tree with uint32_t keys. */
590typedef AVLOHCPHYSTREE *PAVLOHCPHYSTREE;
591
592/** Pointer to an internal tree pointer.
593 * In this case it's a pointer to a relative offset. */
594typedef AVLOHCPHYSTREE *PPAVLOHCPHYSNODECORE;
595
596/** Callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy(). */
597typedef DECLCALLBACK(int) AVLOHCPHYSCALLBACK(PAVLOHCPHYSNODECORE pNode, void *pvUser);
598/** Pointer to callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy(). */
599typedef AVLOHCPHYSCALLBACK *PAVLOHCPHYSCALLBACK;
600
601RTDECL(bool) RTAvloHCPhysInsert(PAVLOHCPHYSTREE pTree, PAVLOHCPHYSNODECORE pNode);
602RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysRemove(PAVLOHCPHYSTREE pTree, RTHCPHYS Key);
603RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysGet(PAVLOHCPHYSTREE pTree, RTHCPHYS Key);
604RTDECL(int) RTAvloHCPhysDoWithAll(PAVLOHCPHYSTREE pTree, int fFromLeft, PAVLOHCPHYSCALLBACK pfnCallBack, void *pvParam);
605RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysGetBestFit(PAVLOHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
606RTDECL(PAVLOHCPHYSNODECORE) RTAvloHCPhysRemoveBestFit(PAVLOHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
607RTDECL(int) RTAvloHCPhysDestroy(PAVLOHCPHYSTREE pTree, PAVLOHCPHYSCALLBACK pfnCallBack, void *pvParam);
608
609/** @} */
610
611
612
613/** AVL tree of RTIOPORTs - using relative offsets internally.
614 * @{
615 */
616
617/**
618 * AVL 'pointer' type for the relative offset pointer scheme.
619 */
620typedef int32_t AVLOIOPORTPTR;
621
622/**
623 * AVL Core node.
624 */
625typedef struct _AVLOIOPortNodeCore
626{
627 /** Offset to the left leaf node, relative to this field. */
628 AVLOIOPORTPTR pLeft;
629 /** Offset to the right leaf node, relative to this field. */
630 AVLOIOPORTPTR pRight;
631 /** Key value. */
632 RTIOPORT Key;
633 /** Height of this tree: max(height(left), height(right)) + 1 */
634 unsigned char uchHeight;
635} AVLOIOPORTNODECORE, *PAVLOIOPORTNODECORE;
636
637/** A offset base tree with uint32_t keys. */
638typedef AVLOIOPORTPTR AVLOIOPORTTREE;
639/** Pointer to a offset base tree with uint32_t keys. */
640typedef AVLOIOPORTTREE *PAVLOIOPORTTREE;
641
642/** Pointer to an internal tree pointer.
643 * In this case it's a pointer to a relative offset. */
644typedef AVLOIOPORTTREE *PPAVLOIOPORTNODECORE;
645
646/** Callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy(). */
647typedef DECLCALLBACK(int) AVLOIOPORTCALLBACK(PAVLOIOPORTNODECORE pNode, void *pvUser);
648/** Pointer to callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy(). */
649typedef AVLOIOPORTCALLBACK *PAVLOIOPORTCALLBACK;
650
651RTDECL(bool) RTAvloIOPortInsert(PAVLOIOPORTTREE pTree, PAVLOIOPORTNODECORE pNode);
652RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortRemove(PAVLOIOPORTTREE pTree, RTIOPORT Key);
653RTDECL(PAVLOIOPORTNODECORE) RTAvloIOPortGet(PAVLOIOPORTTREE pTree, RTIOPORT Key);
654RTDECL(int) RTAvloIOPortDoWithAll(PAVLOIOPORTTREE pTree, int fFromLeft, PAVLOIOPORTCALLBACK pfnCallBack, void *pvParam);
655RTDECL(int) RTAvloIOPortDestroy(PAVLOIOPORTTREE pTree, PAVLOIOPORTCALLBACK pfnCallBack, void *pvParam);
656
657/** @} */
658
659
660/** AVL tree of RTIOPORT ranges - using relative offsets internally.
661 * @{
662 */
663
664/**
665 * AVL 'pointer' type for the relative offset pointer scheme.
666 */
667typedef int32_t AVLROIOPORTPTR;
668
669/**
670 * AVL Core node.
671 */
672typedef struct _AVLROIOPortNodeCore
673{
674 /** First key value in the range (inclusive). */
675 RTIOPORT Key;
676 /** Last key value in the range (inclusive). */
677 RTIOPORT KeyLast;
678 /** Offset to the left leaf node, relative to this field. */
679 AVLROIOPORTPTR pLeft;
680 /** Offset to the right leaf node, relative to this field. */
681 AVLROIOPORTPTR pRight;
682 /** Height of this tree: max(height(left), height(right)) + 1 */
683 unsigned char uchHeight;
684} AVLROIOPORTNODECORE, *PAVLROIOPORTNODECORE;
685
686/** A offset base tree with uint32_t keys. */
687typedef AVLROIOPORTPTR AVLROIOPORTTREE;
688/** Pointer to a offset base tree with uint32_t keys. */
689typedef AVLROIOPORTTREE *PAVLROIOPORTTREE;
690
691/** Pointer to an internal tree pointer.
692 * In this case it's a pointer to a relative offset. */
693typedef AVLROIOPORTTREE *PPAVLROIOPORTNODECORE;
694
695/** Callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy(). */
696typedef DECLCALLBACK(int) AVLROIOPORTCALLBACK(PAVLROIOPORTNODECORE pNode, void *pvUser);
697/** Pointer to callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy(). */
698typedef AVLROIOPORTCALLBACK *PAVLROIOPORTCALLBACK;
699
700RTDECL(bool) RTAvlroIOPortInsert(PAVLROIOPORTTREE pTree, PAVLROIOPORTNODECORE pNode);
701RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRemove(PAVLROIOPORTTREE pTree, RTIOPORT Key);
702RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortGet(PAVLROIOPORTTREE pTree, RTIOPORT Key);
703RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRangeGet(PAVLROIOPORTTREE pTree, RTIOPORT Key);
704RTDECL(PAVLROIOPORTNODECORE) RTAvlroIOPortRangeRemove(PAVLROIOPORTTREE pTree, RTIOPORT Key);
705RTDECL(int) RTAvlroIOPortDoWithAll(PAVLROIOPORTTREE pTree, int fFromLeft, PAVLROIOPORTCALLBACK pfnCallBack, void *pvParam);
706RTDECL(int) RTAvlroIOPortDestroy(PAVLROIOPORTTREE pTree, PAVLROIOPORTCALLBACK pfnCallBack, void *pvParam);
707
708/** @} */
709
710
711/** AVL tree of RTHCPHYSes.
712 * @{
713 */
714
715/**
716 * AVL 'pointer' type for the relative offset pointer scheme.
717 */
718typedef struct _AVLHCPhysNodeCore *AVLHCPHYSPTR;
719
720/**
721 * AVL Core node.
722 */
723typedef struct _AVLHCPhysNodeCore
724{
725 /** Offset to the left leaf node, relative to this field. */
726 AVLHCPHYSPTR pLeft;
727 /** Offset to the right leaf node, relative to this field. */
728 AVLHCPHYSPTR pRight;
729 /** Key value. */
730 RTHCPHYS Key;
731 /** Height of this tree: max(height(left), height(right)) + 1 */
732 unsigned char uchHeight;
733} AVLHCPHYSNODECORE, *PAVLHCPHYSNODECORE;
734
735/** A offset base tree with RTHCPHYS keys. */
736typedef AVLHCPHYSPTR AVLHCPHYSTREE;
737/** Pointer to a offset base tree with RTHCPHYS keys. */
738typedef AVLHCPHYSTREE *PAVLHCPHYSTREE;
739
740/** Pointer to an internal tree pointer.
741 * In this case it's a pointer to a relative offset. */
742typedef AVLHCPHYSTREE *PPAVLHCPHYSNODECORE;
743
744/** Callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy(). */
745typedef DECLCALLBACK(int) AVLHCPHYSCALLBACK(PAVLHCPHYSNODECORE pNode, void *pvUser);
746/** Pointer to callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy(). */
747typedef AVLHCPHYSCALLBACK *PAVLHCPHYSCALLBACK;
748
749RTDECL(bool) RTAvlHCPhysInsert(PAVLHCPHYSTREE pTree, PAVLHCPHYSNODECORE pNode);
750RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysRemove(PAVLHCPHYSTREE pTree, RTHCPHYS Key);
751RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysGet(PAVLHCPHYSTREE pTree, RTHCPHYS Key);
752RTDECL(int) RTAvlHCPhysDoWithAll(PAVLHCPHYSTREE pTree, int fFromLeft, PAVLHCPHYSCALLBACK pfnCallBack, void *pvParam);
753RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysGetBestFit(PAVLHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
754RTDECL(PAVLHCPHYSNODECORE) RTAvlHCPhysRemoveBestFit(PAVLHCPHYSTREE ppTree, RTHCPHYS Key, bool fAbove);
755RTDECL(int) RTAvlHCPhysDestroy(PAVLHCPHYSTREE pTree, PAVLHCPHYSCALLBACK pfnCallBack, void *pvParam);
756
757/** @} */
758
759
760/** @} */
761
762__END_DECLS
763
764#endif
765
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use