IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 18, 2004, 4:01:44 PM (22 years ago)
Author:
Paul Price
Message:

Updating from SDRS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/include/psList.h

    r1579 r1580  
    1 #if !defined(PS_DLIST_H)
    2 #define PS_DLIST_H
     1#if !defined(PS_LIST_H)
     2#define PS_LIST_H
    33
    4 /** \file psDlist.h
     4/** \file psList.h
    55 *  \brief Support for doubly linked lists
    66 *  \ingroup DataGroup
     
    88
    99/** Doubly-linked list element */
    10 typedef struct psDlistElem {
    11    struct psDlistElem *prev;            ///< previous link in list
    12    struct psDlistElem *next;            ///< next link in list
     10typedef struct psListElem {
     11   struct psListElem *prev;             ///< previous link in list
     12   struct psListElem *next;             ///< next link in list
    1313   void *data;                          ///< real data item
    14 } psDlistElem;
     14} psListElem;
    1515
    1616/** Doubly-linked list */
    1717typedef struct {
    18    int n;                               ///< number of elements on list
    19    psDlistElem *head;                   ///< first element on list (may be NULL)
    20    psDlistElem *tail;                   ///< last element on list (may be NULL)
    21    psDlistElem *iter;                   ///< iteration cursor
    22 } psDlist;
     18   unsigned int size;                   ///< number of elements on list
     19   psListElem *head;                    ///< first element on list (may be NULL)
     20   psListElem *tail;                    ///< last element on list (may be NULL)
     21   psListElem *iter;                    ///< iteration cursor
     22   unsigned int iterIndex;              ///< the numeric position of the iteration cursor in the list
     23   pthread_mutex_t lock;                ///< mutex to lock a node during changes
     24} psList;
    2325
    2426/** Special values of index into list */
    2527enum {
    26    PS_DLIST_HEAD = 0,                   ///< at head
    27    PS_DLIST_TAIL = -1,                  ///< at tail
    28    PS_DLIST_UNKNOWN = -2,               ///< unknown position
    29    PS_DLIST_PREV = -3,                  ///< previous element
    30    PS_DLIST_NEXT = -4                   ///< next element
     28   PS_LIST_HEAD = 0,                    ///< at head
     29   PS_LIST_TAIL = -1,                   ///< at tail
     30   PS_LIST_UNKNOWN = -2,                ///< unknown position
     31   PS_LIST_PREV = -3,                   ///< previous element
     32   PS_LIST_NEXT = -4                    ///< next element
    3133};
    3234
     
    3739
    3840/** Constructor */
    39 psDlist *psDlistAlloc(void *data)       ///< initial data item; may be NULL
     41psList *psListAlloc(void *data)         ///< initial data item; may be NULL
    4042;
    4143
    4244/** Destructor */
    43 void psDlistFree(psDlist *list,         ///< list to destroy
     45void psListFree(psList *list,           ///< list to destroy
    4446                void (*elemFree)(void *)) ///< destructor for data on list
    4547;
     
    4850
    4951/** Add to list */
    50 psDlist *psDlistAdd(psDlist *list,      ///< list to add to (may be NULL)
    51                     void *data,         ///< data item to add
    52                     int where)          ///< index, PS_DLIST_HEAD, or PS_DLIST_TAIL
    53 ;
    54 
    55 /** Append to a list */
    56 psDlist *psDlistAppend(psDlist *list,   ///< list to append to (may be NULL)
    57                        void *data)      ///< data item to add
     52bool *psListAdd(psList *list,           ///< list to add to (may be NULL)
     53                void *data,             ///< data item to add
     54                int where)              ///< index, PS_LIST_HEAD, or PS_LIST_TAIL
    5855;
    5956
    6057/** Remove from a list */
    61 void *psDlistRemove(psDlist *list,      ///< list to remove element from
    62                     void *data,         ///< data item to remove
    63                     int which)          ///< index of item, or PS_DLIST_UNKNOWN, PS_DLIST_NEXT, PS_DLIST_PREV
     58bool *psListRemove(psList *list,        ///< list to remove element from
     59                   void *data,          ///< data item to remove
     60                   int which)           ///< index of item, or PS_LIST_UNKNOWN, PS_LIST_NEXT, PS_LIST_PREV
    6461;
    6562
    6663/** Retrieve from a list */
    67 void *psDlistGet(const psDlist *list,   ///< list to retrieve element from
    68                  int which)             ///< index of item, or PS_DLIST_NEXT, PS_DLIST_PREV, PS_DLIST_UNKNOWN
     64void *psListGet(const psList *list,     ///< list to retrieve element from
     65                int which)              ///< index of item, or PS_LIST_NEXT, PS_LIST_PREV, PS_LIST_UNKNOWN
    6966;
    7067
     68/** Convert doubly-linked list to an array of (void *) */
     69psArray *psListToArray(psList *list)    ///< List to convert
     70;
     71
     72/** Convert array to a doubly-linked list */
     73psList *psArrayToList(psArray *array) ///< array of (void *) to convert
     74;
     75
     76/** Sort a list. */
     77psList *psListSort(psList *list,        ///< List to sort
     78                   int (*compare)(const void **a, const void **b) // Function to compare two list elements
     79    );
     80
    7181/** Set the iterator */
    72 void psDlistSetIterator(psDlist *list,  ///< list to retrieve element from
    73                         int where,      ///< index, PS_DLIST_HEAD, or PS_DLIST_TAIL
    74                         int which)      ///< the desired iterator
     82void psListSetIterator(psList *list,    ///< list to retrieve element from
     83                       int where,       ///< index, PS_LIST_HEAD, or PS_LIST_TAIL
     84                       int which)       ///< the desired iterator
    7585;
    7686
    7787/** Get next element relative to iter */
    78 void *psDlistGetNext(psDlist *list,     ///< list to retrieve element from
    79                      int which)         ///< the desired iterator
     88void *psListGetNext(psList *list,       ///< list to retrieve element from
     89                    int which)          ///< the desired iterator
    8090;
    8191
    8292/** Get prev element relative to iter */
    83 void *psDlistGetPrev(psDlist *list,     ///< list to retrieve element from
    84                      int which)         ///< the desired iterator
     93void *psListGetPrevious(psList *list,   ///< list to retrieve element from
     94                        int which)      ///< the desired iterator
    8595;
    86 
    87 /** Convert doubly-linked list to a vector of (void *) */
    88 psVector *psDlistToVector(psDlist *dlist) ///< List to convert
    89 ;
    90 
    91 /** Convert array to a doubly-linked list */
    92 psDlist *psArrayToDlist(psVector *vector) ///< vector of (void *) to convert
    93 ;
    94 
    95 /** Sort a list. */
    96 psDlist *psDlistSort(psDlist *list,     ///< List to sort
    97                      int (*compare)(const void *a, const void *b) // Function to compare two list elements
    98     );
    9996
    10097/* \} */ // End of DataGroup Functions
Note: See TracChangeset for help on using the changeset viewer.