Changeset 4457 for trunk/psLib/src/collections/psList.c
- Timestamp:
- Jul 5, 2005, 5:04:35 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psList.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psList.c
r4392 r4457 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-0 6-25 02:02:05 $8 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-07-06 03:04:35 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 113 113 } 114 114 115 list-> size--;115 list->n--; 116 116 117 117 pthread_mutex_unlock(&list->lock) … … 131 131 psMemSetDeallocator(list, (psFreeFunc) listFree); 132 132 133 list-> size= 0;133 list->n = 0; 134 134 list->head = list->tail = NULL; 135 135 list->iterators = psArrayAlloc(16); … … 182 182 183 183 bool psListIteratorSet(psListIterator* iterator, 184 intlocation)184 long location) 185 185 { 186 186 if (iterator == NULL) { … … 192 192 if (location == PS_LIST_TAIL) { 193 193 iterator->cursor = list->tail; 194 iterator->index = list-> size- 1;194 iterator->index = list->n - 1; 195 195 iterator->offEnd = false; 196 196 return true; … … 205 205 206 206 if (location < 0) { 207 location = list-> size+ location;208 } 209 210 if (location < 0 || location >= (int)list-> size) {207 location = list->n + location; 208 } 209 210 if (location < 0 || location >= (int)list->n) { 211 211 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 212 212 PS_ERRORTEXT_psList_LOCATION_INVALID, … … 218 218 int index = iterator->index; 219 219 if (cursor == NULL) { // set the cursor to the head if it is NULL 220 if (location > list-> size/2) { // closer to tail or head?220 if (location > list->n/2) { // closer to tail or head? 221 221 cursor = list->tail; 222 index = list-> size- 1;222 index = list->n - 1; 223 223 } else { 224 224 cursor = list->head; … … 262 262 } 263 263 264 if (location > 0 && location >= (int)list-> size) {264 if (location > 0 && location >= (int)list->n) { 265 265 psLogMsg(__func__,PS_LOG_WARN, 266 266 "Specified location, %d, is beyond the end of the list. " … … 337 337 elem->data = psMemIncrRefCounter(data); 338 338 339 list-> size++;339 list->n++; 340 340 341 341 if (cursor == list->tail) { … … 412 412 elem->data = psMemIncrRefCounter(data); 413 413 414 list-> size++;414 list->n++; 415 415 416 416 if (cursor == list->head) { … … 548 548 if ( (iterator->cursor == NULL) && (iterator->offEnd) ) { 549 549 iterator->cursor = iterator->list->tail; 550 iterator->index = iterator->list-> size-1;550 iterator->index = iterator->list->n-1; 551 551 iterator->offEnd = false; 552 552 return NULL; … … 574 574 } 575 575 576 if (list-> size> 0) {577 arr = psArrayAlloc(list-> size);576 if (list->n > 0) { 577 arr = psArrayAlloc(list->n); 578 578 } else { 579 579 arr = psArrayAlloc(1); 580 580 } 581 581 582 arr->n = list-> size;582 arr->n = list->n; 583 583 584 584 ptr = list->head; 585 n = list-> size;585 n = list->n; 586 586 for (psS32 i = 0; i < n; i++) { 587 587 arr->data[i] = psMemIncrRefCounter(ptr->data);
Note:
See TracChangeset
for help on using the changeset viewer.
