VirtualBox

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

Last change on this file since 84546 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

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