IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1747


Ignore:
Timestamp:
Sep 8, 2004, 4:23:27 PM (22 years ago)
Author:
desonia
Message:

changed order of psListAdd/psListRemove to match current SDRS.

Location:
trunk/psLib/src
Files:
6 edited

Legend:

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

    r1440 r1747  
    1111*  @author George Gusciora, MHPCC
    1212*
    13 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2004-08-09 23:34:57 $
     13*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2004-09-09 02:23:27 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6161            ptr = table->buckets[i];
    6262            while (ptr != NULL) {
    63                 psListAdd(myLinkList, ptr->key, PS_LIST_HEAD);
     63                psListAdd(myLinkList, PS_LIST_HEAD, ptr->key);
    6464                ptr = ptr->next;
    6565            }
  • trunk/psLib/src/collections/psList.c

    r1656 r1747  
    77 *  @author Robert Daniel DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-08-28 03:00:16 $
     9 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-09 02:23:27 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4949
    5050    if (data != NULL) {
    51         psListAdd(list, data, PS_LIST_TAIL);
     51        psListAdd(list, PS_LIST_TAIL, data);
    5252    }
    5353
     
    8181}
    8282
    83 bool psListAdd(psList* list, void *data, int where)
     83bool psListAdd(psList* list, int location, void *data)
    8484{
    8585    psListElem* position;
     
    9595    }
    9696
    97     if (where <= PS_LIST_UNKNOWN) {
     97    if (location <= PS_LIST_UNKNOWN) {
    9898        // / XXX What is the better way to communicate this failure to the caller?
    99         psLogMsg(__func__, PS_LOG_WARN, "The given insert location (%i) for psListAdd is invalid.", where);
     99        psLogMsg(__func__, PS_LOG_WARN, "The given insert location (%i) for psListAdd is invalid.", location);
    100100        return false;
    101101    }
     
    106106    ;
    107107
    108     if (where > 0 && where > list->size) {
     108    if (location > 0 && location > list->size) {
    109109        psLogMsg(__func__, PS_LOG_WARN,
    110                  "Invalid index %d (only %d elements in psList); assuming tail.", where, list->size);
    111         where = PS_LIST_TAIL;
    112     }
    113 
    114     if (where == PS_LIST_TAIL || list->size == 0) {
     110                 "Invalid index %d (only %d elements in psList); assuming tail.", location, list->size);
     111        location = PS_LIST_TAIL;
     112    }
     113
     114    if (location == PS_LIST_TAIL || list->size == 0) {
    115115        // insert the element at the end of the list
    116116        elem->prev = list->tail;
     
    131131    } else {
    132132        // move ourselves to the given position
    133         listSetIterator(list, where, false);
     133        listSetIterator(list, location, false);
    134134        position = listGetIterator(list);
    135135        cursorIndex = listGetIteratorIndex(list);
    136136
    137137        if (position == NULL) {
    138             psError(__func__, "%s failed to move cursor to specified location (%d)", __func__, where);
     138            psError(__func__, "%s failed to move cursor to specified location (%d)", __func__, location);
    139139            position = list->head;         // since we no list->size != 0, this must be non-NULL
    140140        }
     
    163163}
    164164
    165 /*****************************************************************************/
    166165
    167166/*
    168167 * Remove an element from a list
    169168 */
    170 bool psListRemove(psList* list, void *data, int which)
     169bool psListRemove(psList* list, int location, void *data)
    171170{
    172171    psListElem* elem = NULL;    // element to remove
     
    181180    ;
    182181
    183     if (which == PS_LIST_UNKNOWN) {
     182    if (location == PS_LIST_UNKNOWN) {
    184183        // search list for the data item.
    185184
     
    188187        for (psListElem* ptr = list->head; ptr != NULL; ptr = ptr->next) {
    189188            if (ptr->data == data) {
    190                 which = i;
     189                location = i;
    191190                break;
    192191            }
     
    194193        }
    195194
    196         if (which == PS_LIST_UNKNOWN) {
     195        if (location == PS_LIST_UNKNOWN) {
    197196            psError(__func__, "Failed to find item in given psList.");
    198197            pthread_mutex_unlock(&list->lock)
     
    202201    }
    203202    // position the list's cursor to the desired location
    204     listSetIterator(list, which, false);
     203    listSetIterator(list, location, false);
    205204    elem = listGetIterator(list);
    206205    cursorIndex = listGetIteratorIndex(list);
    207206
    208207    if (elem == NULL) {
    209         psError(__func__, "Couldn't position to given index (%d) to remove element from list.", which);
     208        psError(__func__, "Couldn't position to given index (%d) to remove element from list.", location);
    210209        pthread_mutex_unlock(&list->lock)
    211210        ;
     
    374373}
    375374
    376 void *psListGet(psList* list, int which)
     375void *psListGet(psList* list, int location)
    377376{
    378377    psListElem* element;
    379378
    380     psListSetIterator(list, which);
     379    psListSetIterator(list, location);
    381380    element = listGetIterator(list);
    382381
     
    449448    n = arr->n;
    450449    for (int i = 0; i < n; i++) {
    451         psListAdd(list, arr->data[i], PS_LIST_TAIL);
     450        psListAdd(list, PS_LIST_TAIL, arr->data[i]);
    452451    }
    453452
  • trunk/psLib/src/collections/psList.h

    r1474 r1747  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-08-11 20:04:51 $
     12 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-09 02:23:27 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8383bool psListAdd(
    8484    psList* restrict list,             ///< list to add to (if NULL, nothing is done)
    85     void *data,                        ///< data item to add.  If NULL, list is not modified.
    86     int where                          ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location.
     85    int location,                      ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location.
     86    void *data                         ///< data item to add.  If NULL, list is not modified.
    8787);
    8888
    89 /** Remove an item from a list.  If which parameter is PS_LIST_UNKNOWN,
     89/** Remove an item from a list.  If location parameter is PS_LIST_UNKNOWN,
    9090 *
    9191 *  @return bool        TRUE if element is successfully removed, otherwise FALSE.
     
    9494    psList* restrict list,
    9595    ///< list to remove element from
    96     void *data,
    97     ///< if which is PS_LIST_UNKNOWN, data item to find and remove, otherwise this is ignored.
    98     int which
     96    int location,
    9997    ///< index of item, or PS_LIST_UNKNOWN, PS_LIST_NEXT, PS_LIST_PREV, or numbered location.
     98    void *data
     99    ///< if location is PS_LIST_UNKNOWN, data item to find and remove, otherwise this is ignored.
    100100);
    101101
    102102/** Retrieve an item from a list.
    103103 *
    104  *  @return void*       the item corresponding to the which parameter.  If
    105  *                      which is invalid (e.g., a numbered index greater
     104 *  @return void*       the item corresponding to the location parameter.  If
     105 *                      location is invalid (e.g., a numbered index greater
    106106 *                      than the list size or if the list is empty), a
    107107 *                      NULL is returned.
     
    109109void *psListGet(
    110110    psList* restrict list,             ///< list to retrieve element from
    111     int which                          ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN
     111    int location                       ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN
    112112);
    113113
    114 /** Set the iterator of the list to a given position.  If where is invalid the
     114/** Set the iterator of the list to a given position.  If location is invalid the
    115115 *  iterator position is not changed.
    116116 *
     
    118118void psListSetIterator(
    119119    psList* restrict list,             ///< list to retrieve element from
    120     int where                          ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL
     120    int location                       ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL
    121121);
    122122
  • trunk/psLib/src/types/psHash.c

    r1440 r1747  
    1111*  @author George Gusciora, MHPCC
    1212*
    13 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2004-08-09 23:34:57 $
     13*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2004-09-09 02:23:27 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6161            ptr = table->buckets[i];
    6262            while (ptr != NULL) {
    63                 psListAdd(myLinkList, ptr->key, PS_LIST_HEAD);
     63                psListAdd(myLinkList, PS_LIST_HEAD, ptr->key);
    6464                ptr = ptr->next;
    6565            }
  • trunk/psLib/src/types/psList.c

    r1656 r1747  
    77 *  @author Robert Daniel DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-08-28 03:00:16 $
     9 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-09-09 02:23:27 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4949
    5050    if (data != NULL) {
    51         psListAdd(list, data, PS_LIST_TAIL);
     51        psListAdd(list, PS_LIST_TAIL, data);
    5252    }
    5353
     
    8181}
    8282
    83 bool psListAdd(psList* list, void *data, int where)
     83bool psListAdd(psList* list, int location, void *data)
    8484{
    8585    psListElem* position;
     
    9595    }
    9696
    97     if (where <= PS_LIST_UNKNOWN) {
     97    if (location <= PS_LIST_UNKNOWN) {
    9898        // / XXX What is the better way to communicate this failure to the caller?
    99         psLogMsg(__func__, PS_LOG_WARN, "The given insert location (%i) for psListAdd is invalid.", where);
     99        psLogMsg(__func__, PS_LOG_WARN, "The given insert location (%i) for psListAdd is invalid.", location);
    100100        return false;
    101101    }
     
    106106    ;
    107107
    108     if (where > 0 && where > list->size) {
     108    if (location > 0 && location > list->size) {
    109109        psLogMsg(__func__, PS_LOG_WARN,
    110                  "Invalid index %d (only %d elements in psList); assuming tail.", where, list->size);
    111         where = PS_LIST_TAIL;
    112     }
    113 
    114     if (where == PS_LIST_TAIL || list->size == 0) {
     110                 "Invalid index %d (only %d elements in psList); assuming tail.", location, list->size);
     111        location = PS_LIST_TAIL;
     112    }
     113
     114    if (location == PS_LIST_TAIL || list->size == 0) {
    115115        // insert the element at the end of the list
    116116        elem->prev = list->tail;
     
    131131    } else {
    132132        // move ourselves to the given position
    133         listSetIterator(list, where, false);
     133        listSetIterator(list, location, false);
    134134        position = listGetIterator(list);
    135135        cursorIndex = listGetIteratorIndex(list);
    136136
    137137        if (position == NULL) {
    138             psError(__func__, "%s failed to move cursor to specified location (%d)", __func__, where);
     138            psError(__func__, "%s failed to move cursor to specified location (%d)", __func__, location);
    139139            position = list->head;         // since we no list->size != 0, this must be non-NULL
    140140        }
     
    163163}
    164164
    165 /*****************************************************************************/
    166165
    167166/*
    168167 * Remove an element from a list
    169168 */
    170 bool psListRemove(psList* list, void *data, int which)
     169bool psListRemove(psList* list, int location, void *data)
    171170{
    172171    psListElem* elem = NULL;    // element to remove
     
    181180    ;
    182181
    183     if (which == PS_LIST_UNKNOWN) {
     182    if (location == PS_LIST_UNKNOWN) {
    184183        // search list for the data item.
    185184
     
    188187        for (psListElem* ptr = list->head; ptr != NULL; ptr = ptr->next) {
    189188            if (ptr->data == data) {
    190                 which = i;
     189                location = i;
    191190                break;
    192191            }
     
    194193        }
    195194
    196         if (which == PS_LIST_UNKNOWN) {
     195        if (location == PS_LIST_UNKNOWN) {
    197196            psError(__func__, "Failed to find item in given psList.");
    198197            pthread_mutex_unlock(&list->lock)
     
    202201    }
    203202    // position the list's cursor to the desired location
    204     listSetIterator(list, which, false);
     203    listSetIterator(list, location, false);
    205204    elem = listGetIterator(list);
    206205    cursorIndex = listGetIteratorIndex(list);
    207206
    208207    if (elem == NULL) {
    209         psError(__func__, "Couldn't position to given index (%d) to remove element from list.", which);
     208        psError(__func__, "Couldn't position to given index (%d) to remove element from list.", location);
    210209        pthread_mutex_unlock(&list->lock)
    211210        ;
     
    374373}
    375374
    376 void *psListGet(psList* list, int which)
     375void *psListGet(psList* list, int location)
    377376{
    378377    psListElem* element;
    379378
    380     psListSetIterator(list, which);
     379    psListSetIterator(list, location);
    381380    element = listGetIterator(list);
    382381
     
    449448    n = arr->n;
    450449    for (int i = 0; i < n; i++) {
    451         psListAdd(list, arr->data[i], PS_LIST_TAIL);
     450        psListAdd(list, PS_LIST_TAIL, arr->data[i]);
    452451    }
    453452
  • trunk/psLib/src/types/psList.h

    r1474 r1747  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-08-11 20:04:51 $
     12 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-09-09 02:23:27 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8383bool psListAdd(
    8484    psList* restrict list,             ///< list to add to (if NULL, nothing is done)
    85     void *data,                        ///< data item to add.  If NULL, list is not modified.
    86     int where                          ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location.
     85    int location,                      ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location.
     86    void *data                         ///< data item to add.  If NULL, list is not modified.
    8787);
    8888
    89 /** Remove an item from a list.  If which parameter is PS_LIST_UNKNOWN,
     89/** Remove an item from a list.  If location parameter is PS_LIST_UNKNOWN,
    9090 *
    9191 *  @return bool        TRUE if element is successfully removed, otherwise FALSE.
     
    9494    psList* restrict list,
    9595    ///< list to remove element from
    96     void *data,
    97     ///< if which is PS_LIST_UNKNOWN, data item to find and remove, otherwise this is ignored.
    98     int which
     96    int location,
    9997    ///< index of item, or PS_LIST_UNKNOWN, PS_LIST_NEXT, PS_LIST_PREV, or numbered location.
     98    void *data
     99    ///< if location is PS_LIST_UNKNOWN, data item to find and remove, otherwise this is ignored.
    100100);
    101101
    102102/** Retrieve an item from a list.
    103103 *
    104  *  @return void*       the item corresponding to the which parameter.  If
    105  *                      which is invalid (e.g., a numbered index greater
     104 *  @return void*       the item corresponding to the location parameter.  If
     105 *                      location is invalid (e.g., a numbered index greater
    106106 *                      than the list size or if the list is empty), a
    107107 *                      NULL is returned.
     
    109109void *psListGet(
    110110    psList* restrict list,             ///< list to retrieve element from
    111     int which                          ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN
     111    int location                       ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN
    112112);
    113113
    114 /** Set the iterator of the list to a given position.  If where is invalid the
     114/** Set the iterator of the list to a given position.  If location is invalid the
    115115 *  iterator position is not changed.
    116116 *
     
    118118void psListSetIterator(
    119119    psList* restrict list,             ///< list to retrieve element from
    120     int where                          ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL
     120    int location                       ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL
    121121);
    122122
Note: See TracChangeset for help on using the changeset viewer.