Changeset 7 in kStuff for trunk/include/k/kAvlTmpl/kAvlEnum.h
- Timestamp:
- Feb 4, 2008 2:08:02 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/include/k/kAvlTmpl/kAvlEnum.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/k/kAvlTmpl/kAvlEnum.h
r2 r7 51 51 52 52 /** 53 * Ends an enumeration. 54 * 55 * The purpose of this function is to unlock the tree should the 56 * AVL implementation include locking. It's good practice to call 57 * it anyway even if the tree doesn't do any locking. 58 * 59 * @param pEnumData Pointer to enumeration control data. 60 */ 61 KAVL_DECL(void) KAVL_FN(EndEnum)(KAVL_TYPE(,ENUMDATA) *pEnumData) 62 { 63 KAVLROOT pRoot = pEnumData->pRoot; 64 pEnumData->pRoot = NULL; 65 if (pRoot) 66 KAVL_READ_UNLOCK(pEnumData->pRoot); 67 } 68 69 70 /** 53 71 * Get the next node in the tree enumeration. 54 72 * … … 56 74 * chain like the DoWithAll function does. This may be changed later. 57 75 * 58 * @returns Pointer to the first node in the tree. 76 * @returns Pointer to the next node in the tree. 77 * NULL is returned when the end of the tree has been reached, 78 * it is not necessary to call EndEnum in this case. 59 79 * @param pEnumData Pointer to enumeration control data. 60 80 */ … … 130 150 } 131 151 152 /* 153 * Call EndEnum. 154 */ 155 KAVL_FN(EndEnum)(pEnumData); 132 156 return NULL; 133 157 } … … 137 161 * Starts an enumeration of all nodes in the given AVL tree. 138 162 * 139 * The current implementation of this function will lnot walk the mpList163 * The current implementation of this function will not walk the mpList 140 164 * chain like the DoWithAll function does. This may be changed later. 141 165 * 142 166 * @returns Pointer to the first node in the enumeration. 143 * @param ppTree Pointer to the AVL-tree root node pointer. 144 * @param pEnumData Pointer to enumeration control data. 145 * @param fFromLeft K_TRUE: Left to right. 146 * K_FALSE: Right to left. 167 * If NULL is returned the tree is empty calling EndEnum isn't 168 * strictly necessary (although it will do no harm). 169 * @param pRoot Pointer to the AVL-tree root structure. 170 * @param pEnumData Pointer to enumeration control data. 171 * @param fFromLeft K_TRUE: Left to right. 172 * K_FALSE: Right to left. 147 173 */ 148 KAVL_DECL(KAVLNODE *) KAVL_FN(BeginEnum)(KAVL TREEPTR *ppTree, KAVL_TYPE(,ENUMDATA) *pEnumData, KBOOL fFromLeft)174 KAVL_DECL(KAVLNODE *) KAVL_FN(BeginEnum)(KAVLROOT *pRoot, KAVL_TYPE(,ENUMDATA) *pEnumData, KBOOL fFromLeft) 149 175 { 150 if (*ppTree != KAVL_NULL) 176 KAVL_READ_LOCK(pRoot); 177 pEnumData->pRoot = pRoot; 178 if (pRoot->mpRoot != KAVL_NULL) 151 179 { 152 180 pEnumData->fFromLeft = fFromLeft; 153 181 pEnumData->cEntries = 1; 154 pEnumData->aEntries[0] = KAVL_GET_POINTER(p pTree);182 pEnumData->aEntries[0] = KAVL_GET_POINTER(pRoot->mpRoot); 155 183 pEnumData->achFlags[0] = 0; 156 184 }
Note:
See TracChangeset
for help on using the changeset viewer.

