Changeset 1474
- Timestamp:
- Aug 11, 2004, 10:04:51 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 edited
-
collections/psList.h (modified) (14 diffs)
-
types/psList.h (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psList.h
r1441 r1474 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08- 09 23:40:55$12 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-11 20:04:51 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 33 33 */ 34 34 enum { 35 PS_LIST_HEAD = 0, ///< at head36 PS_LIST_TAIL = -1, ///< at tail37 PS_LIST_PREVIOUS = -2, ///< previous element38 PS_LIST_CURRENT = -3, ///< current element39 PS_LIST_NEXT = -4, ///< next element40 PS_LIST_UNKNOWN = -5 ///< unknown position (should be last in enum list)35 PS_LIST_HEAD = 0, ///< at head 36 PS_LIST_TAIL = -1, ///< at tail 37 PS_LIST_PREVIOUS = -2, ///< previous element 38 PS_LIST_CURRENT = -3, ///< current element 39 PS_LIST_NEXT = -4, ///< next element 40 PS_LIST_UNKNOWN = -5 ///< unknown position (should be last in enum list) 41 41 }; 42 42 … … 44 44 typedef struct psListElem 45 45 { 46 struct psListElem* prev; ///< previous link in list47 struct psListElem* next; ///< next link in list48 void *data; ///< real data item46 struct psListElem* prev; ///< previous link in list 47 struct psListElem* next; ///< next link in list 48 void *data; ///< real data item 49 49 } 50 50 psListElem; … … 57 57 typedef struct 58 58 { 59 unsigned int size; ///< number of elements on list60 psListElem* head; ///< first element on list (may be NULL)61 psListElem* tail; ///< last element on list (may be NULL)62 psListElem* iter; ///< iteration cursor63 unsigned int iterIndex; ///< the numeric position of the iteration cursor in the list64 pthread_mutex_t lock; ///< mutex to lock a node during changes59 unsigned int size; ///< number of elements on list 60 psListElem* head; ///< first element on list (may be NULL) 61 psListElem* tail; ///< last element on list (may be NULL) 62 psListElem* iter; ///< iteration cursor 63 unsigned int iterIndex; ///< the numeric position of the iteration cursor in the list 64 pthread_mutex_t lock; ///< mutex to lock a node during changes 65 65 } 66 66 psList; … … 70 70 * @return psList* A new psList object. 71 71 */ 72 psList* psListAlloc(void *data 73 ///< initial data item; may be NULL if no an empty psList is desired 74 ) 72 psList* psListAlloc( 73 void *data 74 ///< initial data item; may be NULL if no an empty psList is desired 75 ) 75 76 ; 76 77 … … 80 81 * NULL, the return value will also be NULL. 81 82 */ 82 bool psListAdd(psList* restrict list, ///< list to add to (if NULL, nothing is done) 83 void *data, ///< data item to add. If NULL, list is not modified. 84 int where ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location. 85 ); 83 bool psListAdd( 84 psList* restrict list, ///< list to add to (if NULL, nothing is done) 85 void *data, ///< data item to add. If NULL, list is not modified. 86 int where ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location. 87 ); 86 88 87 89 /** Remove an item from a list. If which parameter is PS_LIST_UNKNOWN, … … 89 91 * @return bool TRUE if element is successfully removed, otherwise FALSE. 90 92 */ 91 bool psListRemove(psList* restrict list, 92 ///< list to remove element from 93 void *data, 94 ///< if which is PS_LIST_UNKNOWN, data item to find and remove, otherwise this is ignored. 95 int which 96 ///< index of item, or PS_LIST_UNKNOWN, PS_LIST_NEXT, PS_LIST_PREV, or numbered location. 97 ); 93 bool psListRemove( 94 psList* restrict list, 95 ///< list to remove element from 96 void *data, 97 ///< if which is PS_LIST_UNKNOWN, data item to find and remove, otherwise this is ignored. 98 int which 99 ///< index of item, or PS_LIST_UNKNOWN, PS_LIST_NEXT, PS_LIST_PREV, or numbered location. 100 ); 98 101 99 102 /** Retrieve an item from a list. … … 104 107 * NULL is returned. 105 108 */ 106 void *psListGet(psList* restrict list, ///< list to retrieve element from 107 int which ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN 108 ); 109 void *psListGet( 110 psList* restrict list, ///< list to retrieve element from 111 int which ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN 112 ); 109 113 110 114 /** Set the iterator of the list to a given position. If where is invalid the … … 112 116 * 113 117 */ 114 void psListSetIterator(psList* restrict list, ///< list to retrieve element from 115 int where ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL 116 ); 118 void psListSetIterator( 119 psList* restrict list, ///< list to retrieve element from 120 int where ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL 121 ); 117 122 118 123 /** Get next element relative to the iterator. This also moves the iterator to … … 123 128 * parameter was NULL. 124 129 */ 125 void *psListGetNext(psList* restrict list ///< list to retrieve element from 126 ); 130 void *psListGetNext( 131 psList* restrict list ///< list to retrieve element from 132 ); 127 133 128 134 /** Get current element according to the psList's iterator cursor. This does … … 133 139 * iterator is not valid or list parameter was NULL. 134 140 */ 135 void *psListGetCurrent(psList* restrict list ///< list to retrieve element from 136 ); 141 void *psListGetCurrent( 142 psList* restrict list ///< list to retrieve element from 143 ); 137 144 138 145 /** Get previous element relative to list's iterator. This also moves the … … 143 150 * parameter was NULL. 144 151 */ 145 void *psListGetPrevious(psList* restrict list ///< list to retrieve element from 146 ); 152 void *psListGetPrevious( 153 psList* restrict list ///< list to retrieve element from 154 ); 147 155 148 156 /** Convert a linked list to an array … … 151 159 * or NULL if the given dlist parameter is NULL. 152 160 */ 153 psArray* psListToArray(psList* dlist ///< List to convert 154 ); 161 psArray* psListToArray( 162 psList* dlist ///< List to convert 163 ); 155 164 156 165 /** Convert array to a doubly-linked list … … 159 168 * or NULL is the given arr parameter is NULL. 160 169 */ 161 psList* psArrayToList(psArray* arr ///< vector to convert 162 ); 170 psList* psArrayToList( 171 psArray* arr ///< vector to convert 172 ); 163 173 164 psList* psListSort(psList* list, psComparePtrFcn compare); 174 /** Sort a list via a comparison function. 175 * 176 * The comparison function must return an integer less than, equal to, or 177 * greater than zero if the first argument is considered to be respectively 178 * less than, equal to, or greater than the second. 179 * 180 * If two members compare as equal, their order in the sorted array is 181 * undefined. 182 * 183 * @return psList* Sorted list. 184 */ 185 psList* psListSort( 186 psList* list, ///< the list to sort 187 psComparePtrFcn compare ///< the comparison function 188 ); 165 189 166 190 /// @} End of DataGroup Functions -
trunk/psLib/src/types/psList.h
r1441 r1474 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-08- 09 23:40:55$12 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-11 20:04:51 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 33 33 */ 34 34 enum { 35 PS_LIST_HEAD = 0, ///< at head36 PS_LIST_TAIL = -1, ///< at tail37 PS_LIST_PREVIOUS = -2, ///< previous element38 PS_LIST_CURRENT = -3, ///< current element39 PS_LIST_NEXT = -4, ///< next element40 PS_LIST_UNKNOWN = -5 ///< unknown position (should be last in enum list)35 PS_LIST_HEAD = 0, ///< at head 36 PS_LIST_TAIL = -1, ///< at tail 37 PS_LIST_PREVIOUS = -2, ///< previous element 38 PS_LIST_CURRENT = -3, ///< current element 39 PS_LIST_NEXT = -4, ///< next element 40 PS_LIST_UNKNOWN = -5 ///< unknown position (should be last in enum list) 41 41 }; 42 42 … … 44 44 typedef struct psListElem 45 45 { 46 struct psListElem* prev; ///< previous link in list47 struct psListElem* next; ///< next link in list48 void *data; ///< real data item46 struct psListElem* prev; ///< previous link in list 47 struct psListElem* next; ///< next link in list 48 void *data; ///< real data item 49 49 } 50 50 psListElem; … … 57 57 typedef struct 58 58 { 59 unsigned int size; ///< number of elements on list60 psListElem* head; ///< first element on list (may be NULL)61 psListElem* tail; ///< last element on list (may be NULL)62 psListElem* iter; ///< iteration cursor63 unsigned int iterIndex; ///< the numeric position of the iteration cursor in the list64 pthread_mutex_t lock; ///< mutex to lock a node during changes59 unsigned int size; ///< number of elements on list 60 psListElem* head; ///< first element on list (may be NULL) 61 psListElem* tail; ///< last element on list (may be NULL) 62 psListElem* iter; ///< iteration cursor 63 unsigned int iterIndex; ///< the numeric position of the iteration cursor in the list 64 pthread_mutex_t lock; ///< mutex to lock a node during changes 65 65 } 66 66 psList; … … 70 70 * @return psList* A new psList object. 71 71 */ 72 psList* psListAlloc(void *data 73 ///< initial data item; may be NULL if no an empty psList is desired 74 ) 72 psList* psListAlloc( 73 void *data 74 ///< initial data item; may be NULL if no an empty psList is desired 75 ) 75 76 ; 76 77 … … 80 81 * NULL, the return value will also be NULL. 81 82 */ 82 bool psListAdd(psList* restrict list, ///< list to add to (if NULL, nothing is done) 83 void *data, ///< data item to add. If NULL, list is not modified. 84 int where ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location. 85 ); 83 bool psListAdd( 84 psList* restrict list, ///< list to add to (if NULL, nothing is done) 85 void *data, ///< data item to add. If NULL, list is not modified. 86 int where ///< index, PS_LIST_HEAD, PS_LIST_TAIL, or numbered location. 87 ); 86 88 87 89 /** Remove an item from a list. If which parameter is PS_LIST_UNKNOWN, … … 89 91 * @return bool TRUE if element is successfully removed, otherwise FALSE. 90 92 */ 91 bool psListRemove(psList* restrict list, 92 ///< list to remove element from 93 void *data, 94 ///< if which is PS_LIST_UNKNOWN, data item to find and remove, otherwise this is ignored. 95 int which 96 ///< index of item, or PS_LIST_UNKNOWN, PS_LIST_NEXT, PS_LIST_PREV, or numbered location. 97 ); 93 bool psListRemove( 94 psList* restrict list, 95 ///< list to remove element from 96 void *data, 97 ///< if which is PS_LIST_UNKNOWN, data item to find and remove, otherwise this is ignored. 98 int which 99 ///< index of item, or PS_LIST_UNKNOWN, PS_LIST_NEXT, PS_LIST_PREV, or numbered location. 100 ); 98 101 99 102 /** Retrieve an item from a list. … … 104 107 * NULL is returned. 105 108 */ 106 void *psListGet(psList* restrict list, ///< list to retrieve element from 107 int which ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN 108 ); 109 void *psListGet( 110 psList* restrict list, ///< list to retrieve element from 111 int which ///< index number, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN 112 ); 109 113 110 114 /** Set the iterator of the list to a given position. If where is invalid the … … 112 116 * 113 117 */ 114 void psListSetIterator(psList* restrict list, ///< list to retrieve element from 115 int where ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL 116 ); 118 void psListSetIterator( 119 psList* restrict list, ///< list to retrieve element from 120 int where ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL 121 ); 117 122 118 123 /** Get next element relative to the iterator. This also moves the iterator to … … 123 128 * parameter was NULL. 124 129 */ 125 void *psListGetNext(psList* restrict list ///< list to retrieve element from 126 ); 130 void *psListGetNext( 131 psList* restrict list ///< list to retrieve element from 132 ); 127 133 128 134 /** Get current element according to the psList's iterator cursor. This does … … 133 139 * iterator is not valid or list parameter was NULL. 134 140 */ 135 void *psListGetCurrent(psList* restrict list ///< list to retrieve element from 136 ); 141 void *psListGetCurrent( 142 psList* restrict list ///< list to retrieve element from 143 ); 137 144 138 145 /** Get previous element relative to list's iterator. This also moves the … … 143 150 * parameter was NULL. 144 151 */ 145 void *psListGetPrevious(psList* restrict list ///< list to retrieve element from 146 ); 152 void *psListGetPrevious( 153 psList* restrict list ///< list to retrieve element from 154 ); 147 155 148 156 /** Convert a linked list to an array … … 151 159 * or NULL if the given dlist parameter is NULL. 152 160 */ 153 psArray* psListToArray(psList* dlist ///< List to convert 154 ); 161 psArray* psListToArray( 162 psList* dlist ///< List to convert 163 ); 155 164 156 165 /** Convert array to a doubly-linked list … … 159 168 * or NULL is the given arr parameter is NULL. 160 169 */ 161 psList* psArrayToList(psArray* arr ///< vector to convert 162 ); 170 psList* psArrayToList( 171 psArray* arr ///< vector to convert 172 ); 163 173 164 psList* psListSort(psList* list, psComparePtrFcn compare); 174 /** Sort a list via a comparison function. 175 * 176 * The comparison function must return an integer less than, equal to, or 177 * greater than zero if the first argument is considered to be respectively 178 * less than, equal to, or greater than the second. 179 * 180 * If two members compare as equal, their order in the sorted array is 181 * undefined. 182 * 183 * @return psList* Sorted list. 184 */ 185 psList* psListSort( 186 psList* list, ///< the list to sort 187 psComparePtrFcn compare ///< the comparison function 188 ); 165 189 166 190 /// @} End of DataGroup Functions
Note:
See TracChangeset
for help on using the changeset viewer.
