IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 19, 2004, 11:01:12 AM (22 years ago)
Author:
desonia
Message:

from IP3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sysUtils/psDList.h

    r453 r454  
    1 //
    2 // C++ Interface: psDList
    3 //
    4 // Description:
    5 //
    6 //
    7 // Author: Robert DeSonia <robert.desonia@mhpcc.hpc.mil>, (C) 2004
    8 //
    9 // Copyright: See COPYING file that comes with this distribution
    10 //
    11 //
     1#if !defined(PS_DLIST_H)
     2#define PS_DLIST_H
     3
     4/** \file psDlist.h
     5 *  \brief Support for doubly linked lists
     6 *  \ingroup DataGroup
     7 */
     8
     9/** Doubly-linked list element */
     10typedef struct psDlistElem
     11{
     12    struct psDlistElem *prev;  ///< previous link in list
     13    struct psDlistElem *next;  ///< next link in list
     14    void *data;    ///< real data item
     15}
     16psDlistElem;
     17
     18/** Doubly-linked list */
     19typedef struct
     20{
     21    int n;    ///< number of elements on list
     22    psDlistElem *head;   ///< first element on list (may be NULL)
     23    psDlistElem *tail;   ///< last element on list (may be NULL)
     24    psDlistElem *iter;   ///< iteration cursor
     25}
     26psDlist;
     27
     28/** Special values of index into list */
     29enum {
     30    PS_DLIST_HEAD = 0,   ///< at head
     31    PS_DLIST_TAIL = -1,   ///< at tail
     32    PS_DLIST_UNKNOWN = -2,  ///< unknown position
     33    PS_DLIST_PREV = -3,   ///< previous element
     34    PS_DLIST_NEXT = -4   ///< next element
     35};
     36
     37/** Functions **************************************************************/
     38/** \addtogroup DataGroup General Data Container Utilities
     39 *  \{
     40 */
     41
     42/** Constructor */
     43psDlist *psDlistAlloc(void *data) ///< initial data item; may be NULL
     44;
     45
     46/** Destructor */
     47void psDlistFree(psDlist *list,  ///< list to destroy
     48                 void (*elemFree)(void *)) ///< destructor for data on list
     49;
     50
     51/**** List maintainence functions ****/
     52
     53/** Add to list */
     54psDlist *psDlistAdd(psDlist *list, ///< list to add to (may be NULL)
     55                    void *data,  ///< data item to add
     56                    int where)  ///< index, PS_DLIST_HEAD, or PS_DLIST_TAIL
     57;
     58
     59/** Append to a list */
     60psDlist *psDlistAppend(psDlist *list, ///< list to append to (may be NULL)
     61                       void *data) ///< data item to add
     62;
     63
     64/** Remove from a list */
     65void *psDlistRemove(psDlist *list, ///< list to remove element from
     66                    void *data,  ///< data item to remove
     67                    int which)  ///< index of item, or PS_DLIST_UNKNOWN, PS_DLIST_NEXT, PS_DLIST_PREV
     68;
     69
     70/** Retrieve from a list */
     71void *psDlistGet(const psDlist *list, ///< list to retrieve element from
     72                 int which)  ///< index of item, or PS_DLIST_NEXT, PS_DLIST_PREV, PS_DLIST_UNKNOWN
     73;
     74
     75/** Set the iterator */
     76void psDlistSetIterator(psDlist *list, ///< list to retrieve element from
     77                        int where) ///< index, PS_DLIST_HEAD, or PS_DLIST_TAIL
     78;
     79
     80/** Get next element relative to iter */
     81void *psDlistGetNext(psDlist *list) ///< list to retrieve element from
     82;
     83
     84/** Get prev element relative to iter */
     85void *psDlistGetPrev(psDlist *list) ///< list to retrieve element from
     86;
     87
     88/** Convert doubly-linked list to an array */
     89psVoidPtrArray *psDlistToArray(psDlist *dlist) ///< List to convert
     90;
     91
     92/** Convert array to a doubly-linked list */
     93psDlist *psArrayToDlist(psVoidPtrArray *arr) ///< Array to convert
     94;
     95
     96/* \} */ // End of DataGroup Functions
     97
     98#endif
Note: See TracChangeset for help on using the changeset viewer.