Changeset 1440 for trunk/psLib/src/collections/psList.c
- Timestamp:
- Aug 9, 2004, 1:34:58 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psList.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psList.c
r1407 r1440 7 7 * @author Robert Daniel DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-08-0 7 00:06:06$9 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-08-09 23:34:57 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 30 30 // private functions. 31 static psListElem *listGetIterator(psList* list);32 static int listGetIteratorIndex(psList * list);33 static void listSetIterator(psList * list, int where, bool lockList);34 static void listFree(psList * list);35 36 psList *psListAlloc(void *data)37 { 38 psList *list = psAlloc(sizeof(psList));31 static psListElem* listGetIterator(psList* list); 32 static int listGetIteratorIndex(psList* list); 33 static void listSetIterator(psList* list, int where, bool lockList); 34 static void listFree(psList* list); 35 36 psList* psListAlloc(void *data) 37 { 38 psList* list = psAlloc(sizeof(psList)); 39 39 40 40 p_psMemSetDeallocator(list, (psFreeFcn) listFree); … … 55 55 } 56 56 57 static void listFree(psList * list)57 static void listFree(psList* list) 58 58 { 59 59 if (list == NULL) { … … 64 64 ; 65 65 66 for (psListElem * ptr = list->head; ptr != NULL;) {67 psListElem *next = ptr->next;66 for (psListElem* ptr = list->head; ptr != NULL;) { 67 psListElem* next = ptr->next; 68 68 69 69 psFree(ptr->data); … … 81 81 } 82 82 83 bool psListAdd(psList * list, void *data, int where)84 { 85 psListElem *position;86 psListElem *elem;83 bool psListAdd(psList* list, void *data, int where) 84 { 85 psListElem* position; 86 psListElem* elem; 87 87 int cursorIndex = 0; 88 88 … … 168 168 * Remove an element from a list 169 169 */ 170 bool psListRemove(psList * list, void *data, int which)171 { 172 psListElem *elem = NULL; // element to remove170 bool psListRemove(psList* list, void *data, int which) 171 { 172 psListElem* elem = NULL; // element to remove 173 173 int cursorIndex = 0; 174 174 … … 186 186 int i = 0; // index 187 187 188 for (psListElem * ptr = list->head; ptr != NULL; ptr = ptr->next) {188 for (psListElem* ptr = list->head; ptr != NULL; ptr = ptr->next) { 189 189 if (ptr->data == data) { 190 190 which = i; … … 243 243 } 244 244 245 void psListSetIterator(psList * list, int where)245 void psListSetIterator(psList* list, int where) 246 246 { 247 247 listSetIterator(list, where, true); 248 248 } 249 249 250 void listSetIterator(psList * list, int where, bool lockList)251 { 252 psListElem *cursor;250 void listSetIterator(psList* list, int where, bool lockList) 251 { 252 psListElem* cursor; 253 253 int position; 254 254 … … 340 340 } 341 341 342 psListElem *listGetIterator(psList* list)342 psListElem* listGetIterator(psList* list) 343 343 { 344 344 if (list == NULL) { … … 355 355 } 356 356 357 int listGetIteratorIndex(psList * list)357 int listGetIteratorIndex(psList* list) 358 358 { 359 359 if (list->iter == ITER_INIT_HEAD) { … … 366 366 } 367 367 368 void *psListGet(psList * list, int which)369 { 370 psListElem *element;368 void *psListGet(psList* list, int which) 369 { 370 psListElem* element; 371 371 372 372 psListSetIterator(list, which); … … 383 383 * and now return the previous/next element of the list 384 384 */ 385 void *psListGetNext(psList * list)385 void *psListGetNext(psList* list) 386 386 { 387 387 return psListGet(list, PS_LIST_NEXT); 388 388 } 389 389 390 void *psListGetPrevious(psList * list)390 void *psListGetPrevious(psList* list) 391 391 { 392 392 return psListGet(list, PS_LIST_PREVIOUS); 393 393 } 394 394 395 void *psListGetCurrent(psList * list)395 void *psListGetCurrent(psList* list) 396 396 { 397 397 return psListGet(list, PS_LIST_CURRENT); … … 401 401 * Convert a psList to/from a psVoidPtrArray 402 402 */ 403 psArray *psListToArray(psList* restrict list)404 { 405 psListElem *ptr;403 psArray* psListToArray(psList* restrict list) 404 { 405 psListElem* ptr; 406 406 unsigned int n; 407 psArray *restrict arr;407 psArray* restrict arr; 408 408 409 409 if (list == NULL) { … … 429 429 } 430 430 431 psList *psArrayToList(psArray* arr)431 psList* psArrayToList(psArray* arr) 432 432 { 433 433 unsigned int n; 434 psList *list; // list of elements434 psList* list; // list of elements 435 435 436 436 if (arr == NULL) { … … 447 447 } 448 448 449 psList *psListSort(psList* list, psComparePtrFcn compare)450 { 451 psArray *arr;449 psList* psListSort(psList* list, psComparePtrFcn compare) 450 { 451 psArray* arr; 452 452 453 453 if (list == NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.
