Changeset 14927
- Timestamp:
- Sep 20, 2007, 1:56:57 PM (19 years ago)
- Location:
- trunk/psLib/src/types
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psArray.c
r12289 r14927 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.6 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2007-0 3-07 02:50:15$11 * @version $Revision: 1.62 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-09-20 23:56:57 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 163 163 } 164 164 165 // drop an item from the array and free it 165 166 bool psArrayRemoveData(psArray* array, 166 167 const psPtr data) … … 185 186 } 186 187 188 // drop an item from the array and do not free it: this 189 // can be useful in the free function of a data type 190 // with a reference on another structure 191 bool psArrayRemoveDataNoFree(psArray* array, 192 const psPtr data) 193 { 194 PS_ASSERT_ARRAY_NON_NULL(array, false); 195 PS_ASSERT_PTR_NON_NULL(data, false); 196 197 bool success = false; 198 long n = array->n; 199 psPtr *arrayData = array->data; 200 for (long i = n-1; i >= 0; i--) { 201 if (arrayData[i] == data) { 202 memmove(&arrayData[i],&arrayData[i+1],(n-i-1)*sizeof(psPtr)); 203 n--; 204 success = true; 205 } 206 } 207 array->n = n; // reset the array size to indicate the removed item(s) 208 209 return success; 210 } 211 187 212 bool psArrayRemoveIndex(psArray* array, 188 213 long index) -
trunk/psLib/src/types/psArray.h
r14452 r14927 10 10 * @author Joshua Hoblitt, University of Hawaii 11 11 * 12 * @version $Revision: 1. 49$ $Name: not supported by cvs2svn $13 * @date $Date: 2007-0 8-09 01:40:08$12 * @version $Revision: 1.50 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-09-20 23:56:57 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 161 161 162 162 163 /** Remove an element from the array by it's pointer WITHOUT freeing 164 * 165 * Finds and removes the specified data pointer from the list, but does not free it 166 * 167 * @return bool: TRUE if the specified data pointer was found and removed, 168 * otherwise FALSE. 169 * 170 */ 171 bool psArrayRemoveDataNoFree( 172 psArray* array, ///< array to operate on 173 const psPtr data ///< the data pointer to remove from psArray 174 ); 175 176 163 177 /** Remove an element from the array 164 178 *
Note:
See TracChangeset
for help on using the changeset viewer.
