Changeset 912
- Timestamp:
- Jun 7, 2004, 4:18:15 PM (22 years ago)
- Location:
- trunk/psLib/src/collections
- Files:
-
- 2 edited
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 -
trunk/psLib/src/collections/psDlist.h
r886 r912 9 9 * @author Robert Daniel DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-06-0 5 19:12:51$11 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-06-08 02:18:15 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 16 16 17 17 #include <pthread.h> // we need a mutex to make this stuff thread safe. 18 19 #include "psVector.h" 18 20 19 21 /** Special values of index into list … … 79 81 /** Append to a list */ 80 82 psDlist* psDlistAppend( 81 psDlist* restrict list, ///< list to append to (may be NULL)83 psDlist* restrict list, ///< list to append to (may be NULL) 82 84 void *data ///< data item to add 83 85 ); … … 118 120 119 121 /** Convert doubly-linked list to an array */ 120 #if 0 121 psVoidPtrArray *psDlistToArray( 122 psVector* psDlistToVector( 122 123 psDlist *dlist ///< List to convert 123 124 ); 124 125 125 126 /** Convert array to a doubly-linked list */ 126 psDlist *psArrayToDlist(127 psV oidPtrArray *arr ///< Arrayto convert127 psDlist* psVectorToDlist( 128 psVector* arr ///< vector to convert 128 129 ); 129 #endif130 130 131 131 /// @} End of DataGroup Functions
Note:
See TracChangeset
for help on using the changeset viewer.
