VirtualBox

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

Last change on this file since 78377 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

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