IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 2, 2005, 10:22:22 AM (21 years ago)
Author:
evanalst
Message:

Update changes to psList.

File:
1 edited

Legend:

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

    r3085 r3107  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-01-25 01:04:17 $
     8 *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-02-02 20:21:48 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    137137
    138138    // create a default iterator
    139     psListIteratorAlloc(list,PS_LIST_HEAD);
     139    psListIteratorAlloc(list,PS_LIST_HEAD,true);
    140140
    141141    pthread_mutex_init(&(list->lock), NULL)
     
    149149}
    150150
    151 psListIterator* psListIteratorAlloc(psList* list, int location)
     151psListIterator* psListIteratorAlloc(psList* list, int location, bool mutable)
    152152{
    153153    psListIterator* iter = psAlloc(sizeof(psListIterator));
     
    160160    iter->index = 0;
    161161    iter->offEnd = false;
     162    iter->mutable = mutable;
    162163
    163164    // add to the list's array of iterators
     
    201202        iterator->offEnd = false;
    202203        return true;
     204    }
     205
     206    if (location < 0) {
     207        location = list->size + location;
    203208    }
    204209
     
    289294        psError(PS_ERR_BAD_PARAMETER_NULL, true,
    290295                PS_ERRORTEXT_psList_ITERATOR_NULL);
     296        return false;
     297    }
     298
     299    // Check if the list pointed by the iterator can be changed
     300    if (!iterator->mutable) {
     301        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     302                PS_ERRORTEXT_psList_ITERATOR_NONMUTABLE);
    291303        return false;
    292304    }
     
    360372    }
    361373
     374    // Check if the list pointed by the iterator can be changed
     375    if (!iterator->mutable) {
     376        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     377                PS_ERRORTEXT_psList_ITERATOR_NONMUTABLE);
     378        return false;
     379    }
     380
    362381    psListElem* cursor = iterator->cursor;
    363382    psList* list = iterator->list;
     
    493512 * and now return the previous/next element of the list
    494513 */
    495 psPtr psListGetNext(psListIterator* iterator)
     514psPtr psListGetAndIncrement(psListIterator* iterator)
    496515{
    497516    if (iterator == NULL ) {
     
    518537}
    519538
    520 psPtr psListGetPrevious(psListIterator* iterator)
     539psPtr psListGetAndDecrement(psListIterator* iterator)
    521540{
    522541    if (iterator == NULL ) {
Note: See TracChangeset for help on using the changeset viewer.