IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 9, 2004, 4:50:16 PM (22 years ago)
Author:
desonia
Message:

Changed psList API for iterators, etc.

File:
1 edited

Legend:

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

    r2375 r2681  
    1010 *  @ingroup LinkedList
    1111 *
    12  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-11-16 20:00:20 $
     12 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-12-10 02:50:14 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3434    PS_LIST_HEAD = 0,                  ///< at head
    3535    PS_LIST_TAIL = -1,                 ///< at tail
    36     PS_LIST_PREVIOUS = -2,             ///< previous element
    37     PS_LIST_CURRENT = -3,              ///< current element
    38     PS_LIST_NEXT = -4,                 ///< next element
    39     PS_LIST_UNKNOWN = -5               ///< unknown position (should be last in enum list)
    4036};
    4137
     
    5955    psListElem* head;                  ///< first element on list (may be NULL)
    6056    psListElem* tail;                  ///< last element on list (may be NULL)
    61     psArray* iterators;                ///< iterators
     57    psArray* iterators;
     58    ///< array of all iterators associated with this list.  First iterator is
     59    ///< used internally to improve performance when using indexed access, all
     60    ///< others are user-level iterators created by psListIteratorAlloc.
     61
    6262    pthread_mutex_t lock;              ///< mutex to lock a node during changes
    63 psListElem* p_iter;                ///< internal cursor for increased performance index accessing
    64 int p_iterIndex;                   ///< index position of the iter.
    6563}
    6664psList;
     
    7775{
    7876psList* list;                      ///< List iterator to works on
    79 psU32 number;                      ///< List iterator number
    8077psListElem* cursor;                ///< current cursor position
     78int index;                         ///< the index number in the list
    8179bool offEnd;                       ///< Iterator off the end?
    8280}
     
    9492;
    9593
     94/** Creates a psListIterator object and associates it with a psList.
     95 *
     96 *  @return psListIterator* A new psListIterator object.
     97 */
     98psListIterator* psListIteratorAlloc(
     99    psList* list,                      ///< the psList to iterate with
     100    int location                       ///< the initial starting point.
     101    ///<  This can be a numeric index, PS_LIST_HEAD, or PS_LIST_TAIL.
     102);
     103
     104/** Set the iterator of the list to a given position.  If location is invalid the
     105 *  iterator position is not changed.
     106 *
     107 *  @return psBool        TRUE if iterator successfully set, otherwise FALSE.
     108 */
     109psBool psListIteratorSet(
     110    psListIterator* iterator,            ///< list iterator
     111    int location                         ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL
     112);
     113
    96114/** Adds an element to a psList at position given.
    97115 *
    98  *  @return psList* The psList with added data item.  If list parameter is
    99  *                      NULL, the return value will also be NULL.
     116 *  @return psBool        TRUE if item was successfully added, otherwise FALSE.
    100117 */
    101118psBool psListAdd(
    102     psList* restrict list,             ///< list to add to (if NULL, nothing is done)
    103     psS32 location,                      ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location.
     119    psList* restrict list,             ///< list to add item to
     120    psS32 location,                    ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location.
    104121    psPtr data                         ///< data item to add.  If NULL, list is not modified.
    105122);
    106123
    107 /** Remove an item from a list.  If location parameter is PS_LIST_UNKNOWN,
     124/** Adds an data item to a psList at position just after the list position given
     125 *
     126 *  @return psBool        TRUE if item was successfully added, otherwise FALSE.
     127 */
     128psBool psListAddAfter(
     129    psListIterator* list,              ///< list position to add item to
     130    psPtr data                         ///< data item to add.  If NULL, list is not modified.
     131);
     132
     133/** Adds an data item to a psList at position just before the list position given
     134 *
     135 *  @return psBool        TRUE if item was successfully added, otherwise FALSE.
     136 */
     137psBool psListAddBefore(
     138    psListIterator* list,              ///< list position to add item to
     139    psPtr data                         ///< data item to add.  If NULL, list is not modified.
     140);
     141
     142/** Remove an item at the specified location from a list.
    108143 *
    109144 *  @return psBool        TRUE if element is successfully removed, otherwise FALSE.
    110145 */
    111146psBool psListRemove(
    112     psList* restrict list,
    113     ///< list to remove element from
    114     psS32 location,
    115     ///< index of item, or PS_LIST_UNKNOWN, PS_LIST_NEXT, PS_LIST_PREV, or numbered location.
    116     psPtr data
    117     ///< if location is PS_LIST_UNKNOWN, data item to find and remove, otherwise this is ignored.
     147    psList* restrict list,             ///< list to remove element from
     148    psS32 location                     ///< index of item
     149);
     150
     151/** Remove an item from a list.
     152 *
     153 *  @return psBool        TRUE if element is successfully removed, otherwise FALSE.
     154 */
     155psBool psListRemoveData(
     156    psList* restrict list,             ///< list to remove element from
     157    psPtr data                         ///< data item to find and remove
    118158);
    119159
     
    127167psPtr psListGet(
    128168    psList* restrict list,             ///< list to retrieve element from
    129     psS32 location                       ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN
    130 );
    131 
    132 /** Set the iterator of the list to a given position.  If location is invalid the
    133  *  iterator position is not changed.
    134  *
    135  */
    136 void psListSetIterator(
    137     psList* restrict list,             ///< list to retrieve element from
    138     psS32 location                       ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL
    139 );
    140 
    141 /** Get next element relative to the iterator.  This also moves the iterator to
    142  *  the next list position.
    143  *
    144  *  @return psPtr       the data item next on the list or NULL if the iterator
    145  *                      is already pointing to the last element or the list
    146  *                      parameter was NULL.
     169    psS32 location                     ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL
     170);
     171
     172/** Position the specified iterator to the next item in list.
     173 *
     174 *  @return psPtr       the data item at the new iterator position or NULL if the
     175 *                      iterator goes past the end of the list.
    147176 */
    148177psPtr psListGetNext(
    149     psList* restrict list              ///< list to retrieve element from
    150 );
    151 
    152 /** Get current element according to the psList's iterator cursor.  This does
    153  *  not move the iterator location.
    154  *
    155  *  @return psPtr       the data item cooresponding to current iterator
    156  *                      cursor position of the list, or NULL if either the
    157  *                      iterator is not valid or list parameter was NULL.
    158  */
    159 psPtr psListGetCurrent(
    160     psList* restrict list              ///< list to retrieve element from
    161 );
    162 
    163 /** Get previous element relative to list's iterator. This also moves the
    164  *  iterator to the previous list position.
    165  *
    166  *  @return psPtr       the data item previous on the list or NULL if the iterator
    167  *                      is already pointing to the first element or the list
    168  *                      parameter was NULL.
     178    psListIterator* restrict iterator  ///< iterator to move
     179);
     180
     181/** Position the specified iterator to the previous item in list.
     182 *
     183 *  @return psPtr       the data item at the new iterator position or NULL if the
     184 *                      iterator goes past the beginning of the list.
    169185 */
    170186psPtr psListGetPrevious(
    171     psList* restrict list              ///< list to retrieve element from
     187    psListIterator* restrict iterator  ///< iterator to move
    172188);
    173189
Note: See TracChangeset for help on using the changeset viewer.