IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18750


Ignore:
Timestamp:
Jul 25, 2008, 5:49:12 PM (18 years ago)
Author:
eugene
Message:

added psListGetAndRemove (like a POP)

Location:
branches/eam_branch_20080719/psLib/src/types
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080719/psLib/src/types/psList.c

    r17515 r18750  
    77 *  @author Joshua Hoblitt, University of Hawaii
    88 *
    9  *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2008-05-05 00:09:04 $
     9 *  @version $Revision: 1.69.8.1 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2008-07-26 03:49:12 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    437437    PS_ASSERT_LIST_NON_NULL(list, NULL);
    438438
     439    // XXX this should not be an error, right?
    439440    if (list->head == NULL) { // list empty?
    440441        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     
    453454
    454455    return iterator->cursor->data;
     456}
     457
     458// simultaneous get and remove (ie, 'pop')
     459psPtr psListGetAndRemove (psList *list, long location) {
     460
     461    PS_ASSERT_LIST_NON_NULL(list, NULL);
     462
     463    // empty list :
     464    // XXX handle this explicitly since psListGet raises an error in this case
     465    if (list->head == NULL) return NULL;
     466
     467    psPtr *item = psListGet (list, location);
     468
     469    psListRemove (list, location);
     470    return item;
    455471}
    456472
  • branches/eam_branch_20080719/psLib/src/types/psList.h

    r14452 r18750  
    55 *  @author Robert Daniel DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-08-09 01:40:08 $
     7 *  @version $Revision: 1.46.20.1 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2008-07-26 03:49:12 $
    99 *
    1010 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    208208);
    209209
     210/** Retrieve an item from a list.
     211 *
     212 *  @return psPtr       the item corresponding to the location parameter.  If
     213 *                      location is invalid (e.g., a numbered index greater
     214 *                      than the list size or if the list is empty), a
     215 *                      NULL is returned.
     216 */
     217psPtr psListGetAndRemove (
     218    psList *list,                       ///< list from which to get and remove the element
     219    long location                       ///< index of item
     220);
    210221
    211222/** Position the specified iterator to the next item in list.
Note: See TracChangeset for help on using the changeset viewer.