VirtualBox

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

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

Backed out more alignment changes

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