Changeset 28437 in vbox
- Timestamp:
- Apr 17, 2010 9:58:07 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60208
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/list.h
r28435 r28437 155 155 */ 156 156 #define RTListNodeIsDummy(pList, pNode, Type, Member) \ 157 ( (pNode) != RT_FROM_MEMBER((pList), Type, Member) )157 ( (pNode) == RT_FROM_MEMBER((pList), Type, Member) ) 158 158 159 159 /** … … 232 232 233 233 /** 234 * Enumerate the list in reverse order (tail to head). 235 * 236 * @param pList List to enumerate. 237 * @param pIterator The iterator variable name. 238 * @param Type Structure the list node is a member of. 239 * @param Member The list node member name. 240 */ 241 #define RTListForEachReverse(pList, pIterator, Type, Member) \ 242 for (pIterator = RTListNodeGetLast(pList, Type, Member); \ 243 !RTListNodeIsDummy(pList, pIterator, Type, Member); \ 244 pIterator = RT_FROM_MEMBER((pIterator)->Member.pPrev, Type, Member) ) 245 246 247 /** 234 248 * Move the given list to a new list header. 235 249 * -
trunk/src/VBox/Runtime/testcase/tstRTList.cpp
r26813 r28437 54 54 55 55 static void tstRTListOrder(RTTEST hTest, PRTLISTNODE pList, unsigned cElements, 56 unsigned idx Start, unsigned idxEnd, unsigned idxStep)56 unsigned idxFirst, unsigned idxLast, unsigned idxStep) 57 57 { 58 58 RTTEST_CHECK(hTest, RTListIsEmpty(pList) == false); … … 66 66 /* Check that the order is right. */ 67 67 PLISTELEM pNode = RTListNodeGetFirst(pList, LISTELEM, Node); 68 for (unsigned i = idx Start; i < idxEnd; i += idxStep)68 for (unsigned i = idxFirst; i < idxLast; i += idxStep) 69 69 { 70 70 RTTEST_CHECK(hTest, pNode->idx == i); … … 72 72 } 73 73 74 RTTEST_CHECK(hTest, pNode->idx == idx End);74 RTTEST_CHECK(hTest, pNode->idx == idxLast); 75 75 RTTEST_CHECK(hTest, RTListNodeGetLast(pList, LISTELEM, Node) == pNode); 76 76 RTTEST_CHECK(hTest, RTListNodeIsLast(pList, &pNode->Node) == true); … … 78 78 /* Check reverse order */ 79 79 pNode = RTListNodeGetLast(pList, LISTELEM, Node); 80 for (unsigned i = idx End; i > idxStart; i -= idxStep)80 for (unsigned i = idxLast; i > idxFirst; i -= idxStep) 81 81 { 82 82 RTTEST_CHECK(hTest, pNode->idx == i); … … 84 84 } 85 85 86 RTTEST_CHECK(hTest, pNode->idx == idx Start);86 RTTEST_CHECK(hTest, pNode->idx == idxFirst); 87 87 RTTEST_CHECK(hTest, RTListNodeGetFirst(pList, LISTELEM, Node) == pNode); 88 88 RTTEST_CHECK(hTest, RTListNodeIsFirst(pList, &pNode->Node) == true); 89 90 /* The list enumeration. */ 91 unsigned idx = idxFirst; 92 RTListForEach(pList, pNode, LISTELEM, Node) 93 { 94 RTTEST_CHECK_RETV(hTest, idx == pNode->idx); 95 idx += idxStep; 96 } 97 RTTEST_CHECK_MSG_RETV(hTest, idx == idxLast + idxStep || (idx == idxFirst && idxFirst == idxLast), 98 (hTest, "idx=%u idxFirst=%u idxLast=%u idxStep=%u\n", idx, idxFirst, idxLast, idxStep)); 99 100 idx = idxLast; 101 RTListForEachReverse(pList, pNode, LISTELEM, Node) 102 { 103 RTTEST_CHECK_RETV(hTest, idx == pNode->idx); 104 idx -= idxStep; 105 } 106 RTTEST_CHECK_MSG_RETV(hTest, idx == idxFirst - idxStep || (idx == idxLast && idxFirst == idxLast), 107 (hTest, "idx=%u idxFirst=%u idxLast idxStep=%u\n", idx, idxFirst, idxLast, idxStep)); 89 108 } 90 109
Note:
See TracChangeset
for help on using the changeset viewer.