[175] | 1 | /*
|
---|
| 2 | * bltChain.h --
|
---|
| 3 | *
|
---|
| 4 | * Copyright 1993-2000 Lucent Technologies, Inc.
|
---|
| 5 | *
|
---|
| 6 | * Permission to use, copy, modify, and distribute this software and
|
---|
| 7 | * its documentation for any purpose and without fee is hereby
|
---|
| 8 | * granted, provided that the above copyright notice appear in all
|
---|
| 9 | * copies and that both that the copyright notice and warranty
|
---|
| 10 | * disclaimer appear in supporting documentation, and that the names
|
---|
| 11 | * of Lucent Technologies any of their entities not be used in
|
---|
| 12 | * advertising or publicity pertaining to distribution of the software
|
---|
| 13 | * without specific, written prior permission.
|
---|
| 14 | *
|
---|
| 15 | * Lucent Technologies disclaims all warranties with regard to this
|
---|
| 16 | * software, including all implied warranties of merchantability and
|
---|
| 17 | * fitness. In no event shall Lucent Technologies be liable for any
|
---|
| 18 | * special, indirect or consequential damages or any damages
|
---|
| 19 | * whatsoever resulting from loss of use, data or profits, whether in
|
---|
| 20 | * an action of contract, negligence or other tortuous action, arising
|
---|
| 21 | * out of or in connection with the use or performance of this
|
---|
| 22 | * software.
|
---|
| 23 | */
|
---|
| 24 | #ifndef _BLT_CHAIN_H
|
---|
| 25 | #define _BLT_CHAIN_H
|
---|
| 26 |
|
---|
| 27 | typedef struct Blt_ChainLinkStruct Blt_ChainLink;
|
---|
| 28 |
|
---|
| 29 | /*
|
---|
| 30 | * A Blt_ChainLink is the container structure for the Blt_Chain.
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | struct Blt_ChainLinkStruct {
|
---|
| 34 | Blt_ChainLink *prevPtr; /* Link to the previous link */
|
---|
| 35 | Blt_ChainLink *nextPtr; /* Link to the next link */
|
---|
| 36 | ClientData clientData; /* Pointer to the data object */
|
---|
| 37 | };
|
---|
| 38 |
|
---|
| 39 | typedef int (Blt_ChainCompareProc) _ANSI_ARGS_((Blt_ChainLink **l1PtrPtr,
|
---|
| 40 | Blt_ChainLink **l2PtrPtr));
|
---|
| 41 |
|
---|
| 42 | /*
|
---|
| 43 | * A Blt_Chain is a doubly chained list structure.
|
---|
| 44 | */
|
---|
| 45 | typedef struct {
|
---|
| 46 | Blt_ChainLink *headPtr; /* Pointer to first element in chain */
|
---|
| 47 | Blt_ChainLink *tailPtr; /* Pointer to last element in chain */
|
---|
| 48 | int nLinks; /* Number of elements in chain */
|
---|
| 49 | } Blt_Chain;
|
---|
| 50 |
|
---|
| 51 | extern void Blt_ChainInit _ANSI_ARGS_((Blt_Chain * chainPtr));
|
---|
| 52 | extern Blt_Chain *Blt_ChainCreate _ANSI_ARGS_(());
|
---|
| 53 | extern void Blt_ChainDestroy _ANSI_ARGS_((Blt_Chain * chainPtr));
|
---|
| 54 | extern Blt_ChainLink *Blt_ChainNewLink _ANSI_ARGS_((void));
|
---|
| 55 | extern Blt_ChainLink *Blt_ChainAllocLink _ANSI_ARGS_((unsigned int size));
|
---|
| 56 | extern Blt_ChainLink *Blt_ChainAppend _ANSI_ARGS_((Blt_Chain * chainPtr,
|
---|
| 57 | ClientData clientData));
|
---|
| 58 | extern Blt_ChainLink *Blt_ChainPrepend _ANSI_ARGS_((Blt_Chain * chainPtr,
|
---|
| 59 | ClientData clientData));
|
---|
| 60 | extern void Blt_ChainReset _ANSI_ARGS_((Blt_Chain * chainPtr));
|
---|
| 61 | extern void Blt_ChainLinkAfter _ANSI_ARGS_((Blt_Chain * chainPtr,
|
---|
| 62 | Blt_ChainLink * linkPtr, Blt_ChainLink * afterLinkPtr));
|
---|
| 63 | extern void Blt_ChainLinkBefore _ANSI_ARGS_((Blt_Chain * chainPtr,
|
---|
| 64 | Blt_ChainLink * linkPtr, Blt_ChainLink * beforeLinkPtr));
|
---|
| 65 | extern void Blt_ChainUnlinkLink _ANSI_ARGS_((Blt_Chain * chainPtr,
|
---|
| 66 | Blt_ChainLink * linkPtr));
|
---|
| 67 | extern void Blt_ChainDeleteLink _ANSI_ARGS_((Blt_Chain * chainPtr,
|
---|
| 68 | Blt_ChainLink * linkPtr));
|
---|
| 69 | extern Blt_ChainLink *Blt_ChainGetNthLink _ANSI_ARGS_((Blt_Chain * chainPtr, int n));
|
---|
| 70 | extern void Blt_ChainSort _ANSI_ARGS_((Blt_Chain * chainPtr,
|
---|
| 71 | Blt_ChainCompareProc * proc));
|
---|
| 72 |
|
---|
| 73 | #define Blt_ChainGetLength(c) (((c) == NULL) ? 0 : (c)->nLinks)
|
---|
| 74 | #define Blt_ChainFirstLink(c) (((c) == NULL) ? NULL : (c)->headPtr)
|
---|
| 75 | #define Blt_ChainLastLink(c) (((c) == NULL) ? NULL : (c)->tailPtr)
|
---|
| 76 | #define Blt_ChainPrevLink(l) ((l)->prevPtr)
|
---|
| 77 | #define Blt_ChainNextLink(l) ((l)->nextPtr)
|
---|
| 78 | #define Blt_ChainGetValue(l) ((l)->clientData)
|
---|
| 79 | #define Blt_ChainSetValue(l, value) ((l)->clientData = (ClientData)(value))
|
---|
| 80 | #define Blt_ChainAppendLink(c, l) \
|
---|
| 81 | (Blt_ChainLinkBefore((c), (l), (Blt_ChainLink *)NULL))
|
---|
| 82 | #define Blt_ChainPrependLink(c, l) \
|
---|
| 83 | (Blt_ChainLinkAfter((c), (l), (Blt_ChainLink *)NULL))
|
---|
| 84 |
|
---|
| 85 | #endif /* _BLT_CHAIN_H */
|
---|