- Timestamp:
- Feb 25, 2010 10:32:48 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/list.h
r26740 r26813 200 200 (!RTListIsEmpty(pList) ? RTListNodeGetPrev(pList, Type, Member) : NULL) 201 201 202 /** 203 * Move the given list to a new list header. 204 * 205 * @param pListDst The new list. 206 * @param pListSrc The list to move. 207 */ 208 DECLINLINE(void) RTListMove(PRTLISTNODE pListDst, PRTLISTNODE pListSrc) 209 { 210 if (!RTListIsEmpty(pListSrc)) 211 { 212 pListDst->pNext = pListSrc->pNext; 213 pListDst->pPrev = pListSrc->pPrev; 214 215 /* Adjust the first and last element links */ 216 pListDst->pNext->pPrev = pListDst; 217 pListDst->pPrev->pNext = pListDst; 218 219 /* Finally remove the elements from the source list */ 220 RTListInit(pListSrc); 221 } 222 } 223 202 224 RT_C_DECLS_END 203 225 -
trunk/src/VBox/Runtime/testcase/tstRTList.cpp
r26772 r26813 113 113 tstRTListOrder(hTest, &ListHead, cElements, 0, cElements-1, 1); 114 114 115 /* Move the list to a new one. */ 116 RTLISTNODE ListHeadNew; 117 118 RTListInit(&ListHeadNew); 119 RTListMove(&ListHeadNew, &ListHead); 120 121 RTTEST_CHECK(hTest, RTListIsEmpty(&ListHead) == true); 122 RTTEST_CHECK(hTest, RTListNodeGetFirst(&ListHead, LISTELEM, Node) == NULL); 123 RTTEST_CHECK(hTest, RTListNodeGetLast(&ListHead, LISTELEM, Node) == NULL); 124 125 tstRTListOrder(hTest, &ListHeadNew, cElements, 0, cElements-1, 1); 126 115 127 /* Remove elements now */ 116 128 if (cElements > 1) … … 119 131 RTTestISub("Remove every second node"); 120 132 121 PLISTELEM pNode = RTListNodeGetFirst(&ListHead , LISTELEM, Node);133 PLISTELEM pNode = RTListNodeGetFirst(&ListHeadNew, LISTELEM, Node); 122 134 for (unsigned i = 0; i < cElements; i++) 123 135 { … … 137 149 138 150 cElements /= 2; 139 tstRTListOrder(hTest, &ListHead , cElements, 1, idxEnd, 2);151 tstRTListOrder(hTest, &ListHeadNew, cElements, 1, idxEnd, 2); 140 152 } 141 153 142 154 /* Remove the rest now. */ 143 155 RTTestISub("Remove all nodes"); 144 PLISTELEM pNode = RTListNodeGetFirst(&ListHead , LISTELEM, Node);156 PLISTELEM pNode = RTListNodeGetFirst(&ListHeadNew, LISTELEM, Node); 145 157 for (unsigned i = 0; i < cElements; i++) 146 158 { … … 153 165 154 166 /* List should be empty again */ 155 RTTEST_CHECK(hTest, RTListIsEmpty(&ListHead ) == true);156 RTTEST_CHECK(hTest, RTListNodeGetFirst(&ListHead , LISTELEM, Node) == NULL);157 RTTEST_CHECK(hTest, RTListNodeGetLast(&ListHead , LISTELEM, Node) == NULL);167 RTTEST_CHECK(hTest, RTListIsEmpty(&ListHeadNew) == true); 168 RTTEST_CHECK(hTest, RTListNodeGetFirst(&ListHeadNew, LISTELEM, Node) == NULL); 169 RTTEST_CHECK(hTest, RTListNodeGetLast(&ListHeadNew, LISTELEM, Node) == NULL); 158 170 } 159 171
Note:
See TracChangeset
for help on using the changeset viewer.