VirtualBox

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

Last change on this file since 7051 was 7051, checked in by vboxsync, 17 years ago

Realigning after RTGCPHYS change.

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