Changeset 912 for trunk/psLib/src/collections/psDlist.c
- Timestamp:
- Jun 7, 2004, 4:18:15 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psDlist.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psDlist.c
r900 r912 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-0 7 23:18:21$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-08 02:18:15 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 413 413 } 414 414 415 #if 0416 415 /* 417 416 * Convert a psDlist to/from a psVoidPtrArray 418 417 */ 419 psVoidPtrArray *psDlistToArray(psDlist *restrict dlist) 420 { 418 psVector* psDlistToVector(psDlist* restrict dlist) 419 { 420 psDlistElem* ptr; 421 unsigned int n; 422 421 423 if (dlist == NULL) { 422 424 return NULL; 423 425 } 424 426 425 psV oidPtrArray *restrict arr = psVoidPtrArrayAlloc(dlist->size, dlist->size);426 427 psDlistElem *ptr = dlist->head; 428 for (int i = 0, n = dlist->size; i < n; i++) {429 arr->arr[i] = ptr->data;430 431 ptr->data = NULL;427 psVector* restrict arr = psVectorAlloc(dlist->size, PS_TYPE_PTR); 428 arr->n = arr->nalloc; 429 430 ptr = dlist->head; 431 n = dlist->size; 432 for (int i = 0; i < n; i++) { 433 arr->data.PTR[i] = psMemIncrRefCounter(ptr->data); 432 434 ptr = ptr->next; 433 435 } 434 436 435 psDlistFree(dlist, NULL);436 437 437 return arr; 438 438 } 439 439 440 psDlist *psArrayToDlist(psVoidPtrArray *arr) 441 { 442 psDlist *list = psDlistAlloc(NULL); // list of elements 443 444 for (int i = 0, n = arr->size; i < n; i++) { 445 psDlistAppend(list, 446 psMemDecrRefCounter(arr->arr[i])); // it's already Incr 447 arr->arr[i] = NULL; 448 } 449 450 psVoidPtrArrayFree(arr, NULL); 440 psDlist* psVectorToDlist(psVector* arr) 441 { 442 unsigned int n; 443 psDlist* list; // list of elements 444 445 if (arr == NULL) { 446 return NULL; 447 } 448 449 if (arr->type.type != PS_TYPE_PTR) { 450 psError(__func__,"Can not convert a non pointer-vector to a linked list."); 451 return NULL; 452 } 453 454 list = psDlistAlloc(NULL); 455 n = arr->n; 456 for (int i = 0; i < n; i++) { 457 psDlistAppend(list,arr->data.PTR[i]); 458 } 451 459 452 460 return list; 453 461 } 454 455 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
