Changeset 1127
- Timestamp:
- Jun 29, 2004, 1:19:11 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 6 edited
-
collections/psCompare.c (modified) (2 diffs)
-
collections/psList.c (modified) (8 diffs)
-
collections/psList.h (modified) (4 diffs)
-
math/psCompare.c (modified) (2 diffs)
-
types/psList.c (modified) (8 diffs)
-
types/psList.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psCompare.c
r1111 r1127 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-2 8 20:36:37$8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-29 23:19:11 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 21 21 22 22 #define compareNumericPtrDescending(TYPE) \ 23 int psCompare ##TYPE##DescendingPtr(const void** a, const void** b) { \23 int psCompareDescending##TYPE##Ptr(const void** a, const void** b) { \ 24 24 return **((ps##TYPE**)b) - **((ps##TYPE**)a); \ 25 25 } -
trunk/psLib/src/collections/psList.c
r1111 r1127 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-2 8 20:36:37$8 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-29 23:19:11 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 176 176 * Remove an element from a list 177 177 */ 178 void *psListRemove(psList *list, void *data, int which)178 bool psListRemove(psList *list, void *data, int which) 179 179 { 180 180 psListElem *elem = NULL; // element to remove … … 183 183 if (list == NULL) { 184 184 psError(__func__,"list parameter found to be NULL in %s",__func__); 185 return NULL;185 return false; 186 186 } 187 187 … … 204 204 if (which == PS_LIST_UNKNOWN) { 205 205 psError(__func__, "Failed to find item in given psList."); 206 return NULL;206 return false; 207 207 } 208 208 } … … 215 215 if (elem == NULL) { 216 216 psError(__func__, "Couldn't position to given index (%d) to remove element from list.",which); 217 return NULL;217 return false; 218 218 } 219 219 … … 245 245 ; 246 246 247 /* 248 * OK, delete list element and return the data 249 */ 250 data = elem->data; 247 // OK, delete list element and its data 248 psFree(elem->data); 251 249 psFree(elem); 252 return data; 250 251 return true; 253 252 } 254 253 … … 460 459 461 460 462 psList* psListSort(psList* list, psCompare Fcn compare)461 psList* psListSort(psList* list, psComparePtrFcn compare) 463 462 { 464 463 psVector* vector; … … 476 475 // convert back to linked list 477 476 list = psVectorToList(vector); 477 psFree(vector); 478 478 479 479 return list; -
trunk/psLib/src/collections/psList.h
r1111 r1127 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-06-2 8 20:36:37$12 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-06-29 23:19:11 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 17 17 18 18 #include <pthread.h> // we need a mutex to make this stuff thread safe. 19 #include <stdbool.h> // we use the bool type. 19 20 20 21 #include "psCompare.h" … … 98 99 /** Remove an item from a list. If which parameter is PS_LIST_UNKNOWN, 99 100 * 100 * @return void* The data item that was removed. If NULL, no item was 101 * removed. 101 * @return bool TRUE if element is successfully removed, otherwise FALSE. 102 102 */ 103 void*psListRemove(103 bool psListRemove( 104 104 psList* restrict list, 105 105 ///< list to remove element from … … 182 182 ); 183 183 184 psList* psListSort(psList* list, psCompare Fcn compare);184 psList* psListSort(psList* list, psComparePtrFcn compare); 185 185 186 186 /// @} End of DataGroup Functions -
trunk/psLib/src/math/psCompare.c
r1111 r1127 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-2 8 20:36:37$8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-29 23:19:11 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 21 21 22 22 #define compareNumericPtrDescending(TYPE) \ 23 int psCompare ##TYPE##DescendingPtr(const void** a, const void** b) { \23 int psCompareDescending##TYPE##Ptr(const void** a, const void** b) { \ 24 24 return **((ps##TYPE**)b) - **((ps##TYPE**)a); \ 25 25 } -
trunk/psLib/src/types/psList.c
r1111 r1127 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-2 8 20:36:37$8 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-29 23:19:11 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 176 176 * Remove an element from a list 177 177 */ 178 void *psListRemove(psList *list, void *data, int which)178 bool psListRemove(psList *list, void *data, int which) 179 179 { 180 180 psListElem *elem = NULL; // element to remove … … 183 183 if (list == NULL) { 184 184 psError(__func__,"list parameter found to be NULL in %s",__func__); 185 return NULL;185 return false; 186 186 } 187 187 … … 204 204 if (which == PS_LIST_UNKNOWN) { 205 205 psError(__func__, "Failed to find item in given psList."); 206 return NULL;206 return false; 207 207 } 208 208 } … … 215 215 if (elem == NULL) { 216 216 psError(__func__, "Couldn't position to given index (%d) to remove element from list.",which); 217 return NULL;217 return false; 218 218 } 219 219 … … 245 245 ; 246 246 247 /* 248 * OK, delete list element and return the data 249 */ 250 data = elem->data; 247 // OK, delete list element and its data 248 psFree(elem->data); 251 249 psFree(elem); 252 return data; 250 251 return true; 253 252 } 254 253 … … 460 459 461 460 462 psList* psListSort(psList* list, psCompare Fcn compare)461 psList* psListSort(psList* list, psComparePtrFcn compare) 463 462 { 464 463 psVector* vector; … … 476 475 // convert back to linked list 477 476 list = psVectorToList(vector); 477 psFree(vector); 478 478 479 479 return list; -
trunk/psLib/src/types/psList.h
r1111 r1127 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-06-2 8 20:36:37$12 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-06-29 23:19:11 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 17 17 18 18 #include <pthread.h> // we need a mutex to make this stuff thread safe. 19 #include <stdbool.h> // we use the bool type. 19 20 20 21 #include "psCompare.h" … … 98 99 /** Remove an item from a list. If which parameter is PS_LIST_UNKNOWN, 99 100 * 100 * @return void* The data item that was removed. If NULL, no item was 101 * removed. 101 * @return bool TRUE if element is successfully removed, otherwise FALSE. 102 102 */ 103 void*psListRemove(103 bool psListRemove( 104 104 psList* restrict list, 105 105 ///< list to remove element from … … 182 182 ); 183 183 184 psList* psListSort(psList* list, psCompare Fcn compare);184 psList* psListSort(psList* list, psComparePtrFcn compare); 185 185 186 186 /// @} End of DataGroup Functions
Note:
See TracChangeset
for help on using the changeset viewer.
