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