Changeset 33268 in vbox
- Timestamp:
- Oct 20, 2010 3:37:15 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/avl.h
r32284 r33268 124 124 125 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 126 174 /** AVL tree of uint32_t 127 175 * @{ -
trunk/src/VBox/Runtime/common/table/avlrpv.cpp
r33145 r33268 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - AVL tree, void *, unique keys.3 * IPRT - AVL tree, void *, range, unique keys. 4 4 */ 5 5 … … 35 35 * AVL configuration. 36 36 */ 37 #define KAVL_FN(a) RTAvl PV##a37 #define KAVL_FN(a) RTAvlrPV##a 38 38 #define KAVL_MAX_STACK 27 /* Up to 2^24 nodes. */ 39 39 #define KAVL_CHECK_FOR_EQUAL_INSERT 1 /* No duplicate keys! */ 40 #define KAVLNODECORE AVLPVNODECORE 41 #define PKAVLNODECORE PAVLPVNODECORE 42 #define PPKAVLNODECORE PPAVLPVNODECORE 43 #define KAVLKEY AVLPVKEY 44 #define PKAVLKEY PAVLPVKEY 45 #define KAVLENUMDATA AVLPVENUMDATA 46 #define PKAVLENUMDATA PAVLPVENUMDATA 47 #define PKAVLCALLBACK PAVLPVCALLBACK 40 #define KAVLNODECORE AVLRPVNODECORE 41 #define PKAVLNODECORE PAVLRPVNODECORE 42 #define PPKAVLNODECORE PPAVLRPVNODECORE 43 #define KAVLKEY AVLRPVKEY 44 #define PKAVLKEY PAVLRPVKEY 45 #define KAVLENUMDATA AVLRPVENUMDATA 46 #define PKAVLENUMDATA PAVLRPVENUMDATA 47 #define PKAVLCALLBACK PAVLRPVCALLBACK 48 #define KAVL_RANGE 1 48 49 49 50 … … 51 52 * AVL Compare macros 52 53 */ 53 #define KAVL_G(key1, key2) ( (const char*)(key1) > (const char*)(key2) ) 54 #define KAVL_E(key1, key2) ( (const char*)(key1) == (const char*)(key2) ) 55 #define KAVL_NE(key1, key2) ( (const char*)(key1) != (const char*)(key2) ) 54 #define KAVL_G(key1, key2) ( (uintptr_t)(key1) > (uintptr_t)(key2) ) 55 #define KAVL_E(key1, key2) ( (uintptr_t)(key1) == (uintptr_t)(key2) ) 56 #define KAVL_NE(key1, key2) ( (uintptr_t)(key1) != (uintptr_t)(key2) ) 57 #define KAVL_R_IS_IDENTICAL(key1B, key2B, key1E, key2E) ( (uintptr_t)(key1B) == (uintptr_t)(key2B) && (uintptr_t)(key1E) == (uintptr_t)(key2E) ) 58 #define KAVL_R_IS_INTERSECTING(key1B, key2B, key1E, key2E) ( (uintptr_t)(key1B) <= (uintptr_t)(key2E) && (uintptr_t)(key1E) >= (uintptr_t)(key2B) ) 59 #define KAVL_R_IS_IN_RANGE(key1B, key1E, key2) KAVL_R_IS_INTERSECTING(key1B, key2, key1E, key2) 56 60 57 61 … … 72 76 #include "avl_Get.cpp.h" 73 77 #include "avl_GetBestFit.cpp.h" 78 #include "avl_Range.cpp.h" 74 79 #include "avl_RemoveBestFit.cpp.h" 75 80 #include "avl_DoWithAll.cpp.h"
Note:
See TracChangeset
for help on using the changeset viewer.