Changeset 3562 for trunk/kStuff/include/k/kAvlTmpl/kAvlEnum.h
- Timestamp:
- Aug 27, 2007, 12:31:38 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/include/k/kAvlTmpl/kAvlEnum.h
r3560 r3562 25 25 */ 26 26 27 /******************************************************************************* 28 * Structures and Typedefs * 29 *******************************************************************************/ 30 /** 31 * Enumeration control data. 32 * 33 * This is initialized by BeginEnum and used by GetNext to figure out what 34 * to do next. 35 */ 36 typedef struct KAVL_TYPE(,ENUMDATA) 37 { 38 KBOOL fFromLeft; 39 KI8 cEntries; 40 KU8 achFlags[KAVL_MAX_STACK]; 41 KAVLNODE * aEntries[KAVL_MAX_STACK]; 42 } KAVL_TYPE(,ENUMDATA), *KAVL_TYPE(P,ENUMDATA); 43 44 27 45 /** 28 46 * Get the next node in the tree enumeration. 29 * @returns Pointer to the first node in the tree. 30 * @param pEnumData Pointer to enumeration control data. 31 * @status completely implemented. 32 * @author knut st. osmundsen 47 * 48 * @returns Pointer to the first node in the tree. 49 * @param pEnumData Pointer to enumeration control data. 33 50 */ 34 KAVL_DECL(KAVLNODE CORE *) KAVL_FN(GetNextNode)(KAVL_TYPE(,ENUMDATA) *pEnumData)51 KAVL_DECL(KAVLNODE *) KAVL_FN(GetNext)(KAVL_TYPE(,ENUMDATA) *pEnumData) 35 52 { 36 53 if (pEnumData->fFromLeft) … … 38 55 while (pEnumData->cEntries > 0) 39 56 { 40 KAVLNODE CORE*pNode = pEnumData->aEntries[pEnumData->cEntries - 1];57 KAVLNODE *pNode = pEnumData->aEntries[pEnumData->cEntries - 1]; 41 58 42 59 /* left */ … … 44 61 { 45 62 pEnumData->achFlags[pEnumData->cEntries - 1]++; 46 if (pNode-> pLeft != KAVL_NULL)63 if (pNode->mpLeft != KAVL_NULL) 47 64 { 48 65 pEnumData->achFlags[pEnumData->cEntries] = 0; /* 0 left, 1 center, 2 right */ 49 pEnumData->aEntries[pEnumData->cEntries++] = KAVL_GET_POINTER(&pNode-> pLeft);66 pEnumData->aEntries[pEnumData->cEntries++] = KAVL_GET_POINTER(&pNode->mpLeft); 50 67 continue; 51 68 } … … 61 78 /* right */ 62 79 pEnumData->cEntries--; 63 if (pNode-> pRight != KAVL_NULL)80 if (pNode->mpRight != KAVL_NULL) 64 81 { 65 82 pEnumData->achFlags[pEnumData->cEntries] = 0; 66 pEnumData->aEntries[pEnumData->cEntries++] = KAVL_GET_POINTER(&pNode-> pRight);83 pEnumData->aEntries[pEnumData->cEntries++] = KAVL_GET_POINTER(&pNode->mpRight); 67 84 } 68 85 } /* while */ … … 72 89 while (pEnumData->cEntries > 0) 73 90 { 74 KAVLNODE CORE*pNode = pEnumData->aEntries[pEnumData->cEntries - 1];91 KAVLNODE *pNode = pEnumData->aEntries[pEnumData->cEntries - 1]; 75 92 76 93 /* right */ … … 78 95 { 79 96 pEnumData->achFlags[pEnumData->cEntries - 1]++; 80 if (pNode-> pRight != KAVL_NULL)97 if (pNode->mpRight != KAVL_NULL) 81 98 { 82 99 pEnumData->achFlags[pEnumData->cEntries] = 0; /* 0 right, 1 center, 2 left */ 83 pEnumData->aEntries[pEnumData->cEntries++] = KAVL_GET_POINTER(&pNode-> pRight);100 pEnumData->aEntries[pEnumData->cEntries++] = KAVL_GET_POINTER(&pNode->mpRight); 84 101 continue; 85 102 } … … 95 112 /* left */ 96 113 pEnumData->cEntries--; 97 if (pNode-> pLeft != KAVL_NULL)114 if (pNode->mpLeft != KAVL_NULL) 98 115 { 99 116 pEnumData->achFlags[pEnumData->cEntries] = 0; 100 pEnumData->aEntries[pEnumData->cEntries++] = KAVL_GET_POINTER(&pNode-> pLeft);117 pEnumData->aEntries[pEnumData->cEntries++] = KAVL_GET_POINTER(&pNode->mpLeft); 101 118 } 102 119 } /* while */ … … 116 133 * K_FALSE: Right to left. 117 134 */ 118 KAVL_DECL(KAVLNODE CORE *) KAVL_FN(BeginEnumTree)(KAVLTREEPTR *ppTree, KAVL_TYPE(,ENUMDATA) *pEnumData, KBOOL fFromLeft)135 KAVL_DECL(KAVLNODE *) KAVL_FN(BeginEnum)(KAVLTREEPTR *ppTree, KAVL_TYPE(,ENUMDATA) *pEnumData, KBOOL fFromLeft) 119 136 { 120 137 if (*ppTree != KAVL_NULL) … … 128 145 pEnumData->cEntries = 0; 129 146 130 return KAVL_FN(GetNext Node)(pEnumData);147 return KAVL_FN(GetNext)(pEnumData); 131 148 } 132 149
Note:
See TracChangeset
for help on using the changeset viewer.