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