IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1127


Ignore:
Timestamp:
Jun 29, 2004, 1:19:11 PM (22 years ago)
Author:
desonia
Message:

added psListSort function and fixed psListRemove to match the new SDRS (i,e.,
the function now returns a bool instead of a void*).

Location:
trunk/psLib/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psCompare.c

    r1111 r1127  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-28 20:36:37 $
     8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-29 23:19:11 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2121
    2222#define compareNumericPtrDescending(TYPE) \
    23 int psCompare##TYPE##DescendingPtr(const void** a, const void** b) { \
     23int psCompareDescending##TYPE##Ptr(const void** a, const void** b) { \
    2424    return **((ps##TYPE**)b) - **((ps##TYPE**)a); \
    2525}
  • trunk/psLib/src/collections/psList.c

    r1111 r1127  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-28 20:36:37 $
     8 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-29 23:19:11 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    176176 * Remove an element from a list
    177177 */
    178 void *psListRemove(psList *list, void *data,  int which)
     178bool psListRemove(psList *list, void *data,  int which)
    179179{
    180180    psListElem *elem = NULL;  // element to remove
     
    183183    if (list == NULL) {
    184184        psError(__func__,"list parameter found to be NULL in %s",__func__);
    185         return NULL;
     185        return false;
    186186    }
    187187
     
    204204        if (which == PS_LIST_UNKNOWN) {
    205205            psError(__func__, "Failed to find item in given psList.");
    206             return NULL;
     206            return false;
    207207        }
    208208    }
     
    215215    if (elem == NULL) {
    216216        psError(__func__, "Couldn't position to given index (%d) to remove element from list.",which);
    217         return NULL;
     217        return false;
    218218    }
    219219
     
    245245    ;
    246246
    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);
    251249    psFree(elem);
    252     return data;
     250
     251    return true;
    253252}
    254253
     
    460459
    461460
    462 psList* psListSort(psList* list, psCompareFcn compare)
     461psList* psListSort(psList* list, psComparePtrFcn compare)
    463462{
    464463    psVector* vector;
     
    476475    // convert back to linked list
    477476    list = psVectorToList(vector);
     477    psFree(vector);
    478478
    479479    return list;
  • trunk/psLib/src/collections/psList.h

    r1111 r1127  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-06-28 20:36:37 $
     12 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-06-29 23:19:11 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1717
    1818#include <pthread.h>                   // we need a mutex to make this stuff thread safe.
     19#include <stdbool.h>                   // we use the bool type.
    1920
    2021#include "psCompare.h"
     
    9899/** Remove an item from a list.  If which parameter is PS_LIST_UNKNOWN,
    99100 *
    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.
    102102 */
    103 void* psListRemove(
     103bool psListRemove(
    104104    psList* restrict list,
    105105    ///< list to remove element from
     
    182182);
    183183
    184 psList* psListSort(psList* list, psCompareFcn compare);
     184psList* psListSort(psList* list, psComparePtrFcn compare);
    185185
    186186/// @} End of DataGroup Functions
  • trunk/psLib/src/math/psCompare.c

    r1111 r1127  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-28 20:36:37 $
     8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-29 23:19:11 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2121
    2222#define compareNumericPtrDescending(TYPE) \
    23 int psCompare##TYPE##DescendingPtr(const void** a, const void** b) { \
     23int psCompareDescending##TYPE##Ptr(const void** a, const void** b) { \
    2424    return **((ps##TYPE**)b) - **((ps##TYPE**)a); \
    2525}
  • trunk/psLib/src/types/psList.c

    r1111 r1127  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-28 20:36:37 $
     8 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-29 23:19:11 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    176176 * Remove an element from a list
    177177 */
    178 void *psListRemove(psList *list, void *data,  int which)
     178bool psListRemove(psList *list, void *data,  int which)
    179179{
    180180    psListElem *elem = NULL;  // element to remove
     
    183183    if (list == NULL) {
    184184        psError(__func__,"list parameter found to be NULL in %s",__func__);
    185         return NULL;
     185        return false;
    186186    }
    187187
     
    204204        if (which == PS_LIST_UNKNOWN) {
    205205            psError(__func__, "Failed to find item in given psList.");
    206             return NULL;
     206            return false;
    207207        }
    208208    }
     
    215215    if (elem == NULL) {
    216216        psError(__func__, "Couldn't position to given index (%d) to remove element from list.",which);
    217         return NULL;
     217        return false;
    218218    }
    219219
     
    245245    ;
    246246
    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);
    251249    psFree(elem);
    252     return data;
     250
     251    return true;
    253252}
    254253
     
    460459
    461460
    462 psList* psListSort(psList* list, psCompareFcn compare)
     461psList* psListSort(psList* list, psComparePtrFcn compare)
    463462{
    464463    psVector* vector;
     
    476475    // convert back to linked list
    477476    list = psVectorToList(vector);
     477    psFree(vector);
    478478
    479479    return list;
  • trunk/psLib/src/types/psList.h

    r1111 r1127  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-06-28 20:36:37 $
     12 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-06-29 23:19:11 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1717
    1818#include <pthread.h>                   // we need a mutex to make this stuff thread safe.
     19#include <stdbool.h>                   // we use the bool type.
    1920
    2021#include "psCompare.h"
     
    9899/** Remove an item from a list.  If which parameter is PS_LIST_UNKNOWN,
    99100 *
    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.
    102102 */
    103 void* psListRemove(
     103bool psListRemove(
    104104    psList* restrict list,
    105105    ///< list to remove element from
     
    182182);
    183183
    184 psList* psListSort(psList* list, psCompareFcn compare);
     184psList* psListSort(psList* list, psComparePtrFcn compare);
    185185
    186186/// @} End of DataGroup Functions
Note: See TracChangeset for help on using the changeset viewer.