Changeset 1407 for trunk/psLib/src/collections/psList.h
- Timestamp:
- Aug 6, 2004, 2:06:06 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/collections/psList.h (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/collections/psList.h
r1228 r1407 1 1 #if !defined(PS_LIST_H) 2 # define PS_LIST_H2 # define PS_LIST_H 3 3 4 4 /** @file psList.h … … 10 10 * @ingroup LinkedList 11 11 * 12 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-0 7-15 22:18:02$12 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-08-07 00:06:06 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 16 16 */ 17 17 18 # include <pthread.h> // we need a mutex to make this stuff thread safe.19 # include <stdbool.h> // we use the bool type.18 # include <pthread.h> // we need a mutex to make this stuff thread safe. 19 # include <stdbool.h> // we use the bool type. 20 20 21 # include "psCompare.h"22 # include "psArray.h"21 # include "psCompare.h" 22 # include "psArray.h" 23 23 24 24 /** @addtogroup LinkedList … … 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( 73 void *data 74 ///< initial data item; may be NULL if no an empty psList is desired 75 ) 72 psList *psListAlloc(void *data 73 // /< initial data item; may be NULL if no an empty psList is desired 74 ) 76 75 ; 77 76 … … 81 80 * NULL, the return value will also be NULL. 82 81 */ 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 ); 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 ); 88 86 89 87 /** Remove an item from a list. If which parameter is PS_LIST_UNKNOWN, … … 91 89 * @return bool TRUE if element is successfully removed, otherwise FALSE. 92 90 */ 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 ); 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 ); 101 98 102 99 /** Retrieve an item from a list. … … 107 104 * NULL is returned. 108 105 */ 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 ); 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 ); 113 109 114 110 /** Set the iterator of the list to a given position. If where is invalid the … … 116 112 * 117 113 */ 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 ); 114 void psListSetIterator(psList * restrict list, // /< list to retrieve element from 115 int where // /< index number, PS_LIST_HEAD, or PS_LIST_TAIL 116 ); 122 117 123 118 /** Get next element relative to the iterator. This also moves the iterator to … … 128 123 * parameter was NULL. 129 124 */ 130 void* psListGetNext( 131 psList* restrict list ///< list to retrieve element from 132 ); 125 void *psListGetNext(psList * restrict list // /< list to retrieve element from 126 ); 133 127 134 128 /** Get current element according to the psList's iterator cursor. This does … … 139 133 * iterator is not valid or list parameter was NULL. 140 134 */ 141 void* psListGetCurrent( 142 psList* restrict list ///< list to retrieve element from 143 ); 135 void *psListGetCurrent(psList * restrict list // /< list to retrieve element from 136 ); 144 137 145 138 /** Get previous element relative to list's iterator. This also moves the … … 150 143 * parameter was NULL. 151 144 */ 152 void* psListGetPrevious( 153 psList* restrict list ///< list to retrieve element from 154 ); 145 void *psListGetPrevious(psList * restrict list // /< list to retrieve element from 146 ); 155 147 156 148 /** Convert a linked list to an array … … 159 151 * or NULL if the given dlist parameter is NULL. 160 152 */ 161 psArray* psListToArray( 162 psList *dlist ///< List to convert 163 ); 153 psArray *psListToArray(psList * dlist // /< List to convert 154 ); 164 155 165 156 /** Convert array to a doubly-linked list … … 168 159 * or NULL is the given arr parameter is NULL. 169 160 */ 170 psList* psArrayToList( 171 psArray* arr ///< vector to convert 172 ); 161 psList *psArrayToList(psArray * arr // /< vector to convert 162 ); 173 163 174 psList * psListSort(psList* list, psComparePtrFcn compare);164 psList *psListSort(psList * list, psComparePtrFcn compare); 175 165 176 166 /// @} End of DataGroup Functions 177 167 178 168 #endif 179
Note:
See TracChangeset
for help on using the changeset viewer.
