IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3107


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

Update changes to psList.

Location:
trunk/psLib
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psCollectionsErrors.dat

    r2855 r3107  
    3737psList_ITERATOR_INVALID                Specified iterator is not valid.
    3838psList_ITERATOR_NULL                   Specified iterator is NULL.
     39psList_ITERATOR_NONMUTABLE             Specified iterator indicates list is non-mutable.
    3940psList_LIST_NULL                       Specified psList reference is NULL.
    4041psList_DATA_NULL                       Specified data item is NULL.
  • trunk/psLib/src/collections/psCollectionsErrors.h

    r2855 r3107  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-12-30 20:18:36 $
     9 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-02-02 20:21:48 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5454#define PS_ERRORTEXT_psList_ITERATOR_INVALID "Specified iterator is not valid."
    5555#define PS_ERRORTEXT_psList_ITERATOR_NULL "Specified iterator is NULL."
     56#define PS_ERRORTEXT_psList_ITERATOR_NONMUTABLE "Specified iterator indicates list is non-mutable."
    5657#define PS_ERRORTEXT_psList_LIST_NULL "Specified psList reference is NULL."
    5758#define PS_ERRORTEXT_psList_DATA_NULL "Specified data item is NULL."
  • 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 ) {
  • trunk/psLib/src/collections/psList.h

    r2681 r3107  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-12-10 02:50:14 $
     12 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-02-02 20:21:48 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7878int index;                         ///< the index number in the list
    7979bool offEnd;                       ///< Iterator off the end?
     80bool mutable;                      ///< Is it permissible to modify the list?
    8081}
    8182psListIterator;
     
    9899psListIterator* psListIteratorAlloc(
    99100    psList* list,                      ///< the psList to iterate with
    100     int location                       ///< the initial starting point.
     101    int location,                      ///< the initial starting point.
    101102    ///<  This can be a numeric index, PS_LIST_HEAD, or PS_LIST_TAIL.
     103    bool mutable                       ///< Is it permissible to modify list?
    102104);
    103105
     
    175177 *                      iterator goes past the end of the list.
    176178 */
    177 psPtr psListGetNext(
     179psPtr psListGetAndIncrement(
    178180    psListIterator* restrict iterator  ///< iterator to move
    179181);
     
    184186 *                      iterator goes past the beginning of the list.
    185187 */
    186 psPtr psListGetPrevious(
     188psPtr psListGetAndDecrement(
    187189    psListIterator* restrict iterator  ///< iterator to move
    188190);
  • trunk/psLib/src/sys/psErrorCodes.c

    r2703 r3107  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-12-13 20:49:56 $
     9 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-02-02 20:22:22 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7676
    7777        // search dynamic list of error descriptions before giving up.
    78         psListIterator* iter = psListIteratorAlloc(dynamicErrorCodes,PS_LIST_HEAD);
    79         while ((desc = (psErrorDescription*)psListGetNext(iter)) != NULL) {
     78        psListIterator* iter = psListIteratorAlloc(dynamicErrorCodes,PS_LIST_HEAD,true);
     79        while ((desc = (psErrorDescription*)psListGetAndIncrement(iter)) != NULL) {
    8080            if (desc->code == code) {
    8181                psFree(iter);
  • trunk/psLib/src/sysUtils/psErrorCodes.c

    r2703 r3107  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-12-13 20:49:56 $
     9 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-02-02 20:22:22 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7676
    7777        // search dynamic list of error descriptions before giving up.
    78         psListIterator* iter = psListIteratorAlloc(dynamicErrorCodes,PS_LIST_HEAD);
    79         while ((desc = (psErrorDescription*)psListGetNext(iter)) != NULL) {
     78        psListIterator* iter = psListIteratorAlloc(dynamicErrorCodes,PS_LIST_HEAD,true);
     79        while ((desc = (psErrorDescription*)psListGetAndIncrement(iter)) != NULL) {
    8080            if (desc->code == code) {
    8181                psFree(iter);
  • trunk/psLib/src/types/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 ) {
  • trunk/psLib/src/types/psList.h

    r2681 r3107  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-12-10 02:50:14 $
     12 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-02-02 20:21:48 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7878int index;                         ///< the index number in the list
    7979bool offEnd;                       ///< Iterator off the end?
     80bool mutable;                      ///< Is it permissible to modify the list?
    8081}
    8182psListIterator;
     
    9899psListIterator* psListIteratorAlloc(
    99100    psList* list,                      ///< the psList to iterate with
    100     int location                       ///< the initial starting point.
     101    int location,                      ///< the initial starting point.
    101102    ///<  This can be a numeric index, PS_LIST_HEAD, or PS_LIST_TAIL.
     103    bool mutable                       ///< Is it permissible to modify list?
    102104);
    103105
     
    175177 *                      iterator goes past the end of the list.
    176178 */
    177 psPtr psListGetNext(
     179psPtr psListGetAndIncrement(
    178180    psListIterator* restrict iterator  ///< iterator to move
    179181);
     
    184186 *                      iterator goes past the beginning of the list.
    185187 */
    186 psPtr psListGetPrevious(
     188psPtr psListGetAndDecrement(
    187189    psListIterator* restrict iterator  ///< iterator to move
    188190);
  • trunk/psLib/test/astronomy/tst_psMetadataIO.c

    r2681 r3107  
    1313*  @author  Ross Harman, MHPCC
    1414*
    15 *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
    16 *  @date  $Date: 2004-12-10 02:50:15 $
     15*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
     16*  @date  $Date: 2005-02-02 20:20:55 $
    1717*
    1818*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4141    psMetadataItem *entryChild = NULL;
    4242
    43     psListIterator* iter = psListIteratorAlloc(metadataItemList, PS_LIST_HEAD);
     43    psListIterator* iter = psListIteratorAlloc(metadataItemList, PS_LIST_HEAD, true);
    4444
    45     while ( (entryChild=psListGetNext(iter)) != NULL) {
     45    while ( (entryChild=psListGetAndIncrement(iter)) != NULL) {
    4646        printMetadataItem(entryChild, spaces);
    4747    }
  • trunk/psLib/test/astronomy/tst_psMetadata_01.c

    r2681 r3107  
    1818*  @author  Ross Harman, MHPCC
    1919*
    20 *  @version $Revision: 1.17 $  $Name: not supported by cvs2svn $
    21 *  @date  $Date: 2004-12-10 02:50:15 $
     20*  @version $Revision: 1.18 $  $Name: not supported by cvs2svn $
     21*  @date  $Date: 2005-02-02 20:20:55 $
    2222*
    2323*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4646    psMetadataItem *entryChild = NULL;
    4747
    48     psListIterator* iter = psListIteratorAlloc(metadataItemList, PS_LIST_HEAD);
    49 
    50     while ( (entryChild=psListGetNext(iter)) != NULL) {
     48    psListIterator* iter = psListIteratorAlloc(metadataItemList, PS_LIST_HEAD, true);
     49
     50    while ( (entryChild=psListGetAndIncrement(iter)) != NULL) {
    5151        printMetadataItem(entryChild, spaces);
    5252    }
  • trunk/psLib/test/collections/tst_psMetadataIO.c

    r2681 r3107  
    1313*  @author  Ross Harman, MHPCC
    1414*
    15 *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
    16 *  @date  $Date: 2004-12-10 02:50:15 $
     15*  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
     16*  @date  $Date: 2005-02-02 20:20:55 $
    1717*
    1818*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4141    psMetadataItem *entryChild = NULL;
    4242
    43     psListIterator* iter = psListIteratorAlloc(metadataItemList, PS_LIST_HEAD);
     43    psListIterator* iter = psListIteratorAlloc(metadataItemList, PS_LIST_HEAD, true);
    4444
    45     while ( (entryChild=psListGetNext(iter)) != NULL) {
     45    while ( (entryChild=psListGetAndIncrement(iter)) != NULL) {
    4646        printMetadataItem(entryChild, spaces);
    4747    }
  • trunk/psLib/test/collections/tst_psMetadata_01.c

    r2681 r3107  
    1818*  @author  Ross Harman, MHPCC
    1919*
    20 *  @version $Revision: 1.17 $  $Name: not supported by cvs2svn $
    21 *  @date  $Date: 2004-12-10 02:50:15 $
     20*  @version $Revision: 1.18 $  $Name: not supported by cvs2svn $
     21*  @date  $Date: 2005-02-02 20:20:55 $
    2222*
    2323*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4646    psMetadataItem *entryChild = NULL;
    4747
    48     psListIterator* iter = psListIteratorAlloc(metadataItemList, PS_LIST_HEAD);
    49 
    50     while ( (entryChild=psListGetNext(iter)) != NULL) {
     48    psListIterator* iter = psListIteratorAlloc(metadataItemList, PS_LIST_HEAD, true);
     49
     50    while ( (entryChild=psListGetAndIncrement(iter)) != NULL) {
    5151        printMetadataItem(entryChild, spaces);
    5252    }
Note: See TracChangeset for help on using the changeset viewer.