Changeset 2681 for trunk/psLib/src/collections/psList.h
- Timestamp:
- Dec 9, 2004, 4:50:16 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psList.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psList.h
r2375 r2681 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-1 1-16 20:00:20$12 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-12-10 02:50:14 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 34 34 PS_LIST_HEAD = 0, ///< at head 35 35 PS_LIST_TAIL = -1, ///< at tail 36 PS_LIST_PREVIOUS = -2, ///< previous element37 PS_LIST_CURRENT = -3, ///< current element38 PS_LIST_NEXT = -4, ///< next element39 PS_LIST_UNKNOWN = -5 ///< unknown position (should be last in enum list)40 36 }; 41 37 … … 59 55 psListElem* head; ///< first element on list (may be NULL) 60 56 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 62 62 pthread_mutex_t lock; ///< mutex to lock a node during changes 63 psListElem* p_iter; ///< internal cursor for increased performance index accessing64 int p_iterIndex; ///< index position of the iter.65 63 } 66 64 psList; … … 77 75 { 78 76 psList* list; ///< List iterator to works on 79 psU32 number; ///< List iterator number80 77 psListElem* cursor; ///< current cursor position 78 int index; ///< the index number in the list 81 79 bool offEnd; ///< Iterator off the end? 82 80 } … … 94 92 ; 95 93 94 /** Creates a psListIterator object and associates it with a psList. 95 * 96 * @return psListIterator* A new psListIterator object. 97 */ 98 psListIterator* 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 */ 109 psBool psListIteratorSet( 110 psListIterator* iterator, ///< list iterator 111 int location ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL 112 ); 113 96 114 /** Adds an element to a psList at position given. 97 115 * 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. 100 117 */ 101 118 psBool 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. 104 121 psPtr data ///< data item to add. If NULL, list is not modified. 105 122 ); 106 123 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 */ 128 psBool 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 */ 137 psBool 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. 108 143 * 109 144 * @return psBool TRUE if element is successfully removed, otherwise FALSE. 110 145 */ 111 146 psBool 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 */ 155 psBool psListRemoveData( 156 psList* restrict list, ///< list to remove element from 157 psPtr data ///< data item to find and remove 118 158 ); 119 159 … … 127 167 psPtr psListGet( 128 168 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. 147 176 */ 148 177 psPtr 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. 169 185 */ 170 186 psPtr psListGetPrevious( 171 psList * restrict list ///< list to retrieve element from187 psListIterator* restrict iterator ///< iterator to move 172 188 ); 173 189
Note:
See TracChangeset
for help on using the changeset viewer.
