VirtualBox

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

Last change on this file since 71293 was 69854, checked in by vboxsync, 7 years ago

IPRT: Added AVL tree for uint64_t.

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