This is Unofficial EPICS BASE Doxygen Site
ellLib.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
26 #ifndef INC_ellLib_H
27 #define INC_ellLib_H
28 
29 #include "libComAPI.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
45 typedef struct ELLNODE {
46  struct ELLNODE *next;
47  struct ELLNODE *previous;
48 } ELLNODE;
49 
52 #define ELLNODE_INIT {NULL, NULL}
53 
56 typedef struct ELLLIST {
58  int count;
59 } ELLLIST;
60 
63 #define ELLLIST_INIT {ELLNODE_INIT, 0}
64 
71 typedef void (*FREEFUNC)(void *);
72 
76 #define ellInit(PLIST) {\
77  (PLIST)->node.next = (PLIST)->node.previous = NULL;\
78  (PLIST)->count = 0;\
79 }
80 
84 #define ellCount(PLIST) ((PLIST)->count)
85 
89 #define ellFirst(PLIST) ((PLIST)->node.next)
90 
94 #define ellLast(PLIST) ((PLIST)->node.previous)
95 
99 #define ellNext(PNODE) ((PNODE)->next)
100 
104 #define ellPrevious(PNODE) ((PNODE)->previous)
105 
108 #define ellFree(PLIST) ellFree2(PLIST, free)
109 
115 LIBCOM_API void ellAdd (ELLLIST *pList, ELLNODE *pNode);
123 LIBCOM_API void ellConcat (ELLLIST *pDstList, ELLLIST *pAddList);
129 LIBCOM_API void ellDelete (ELLLIST *pList, ELLNODE *pNode);
137 LIBCOM_API void ellExtract (ELLLIST *pSrcList, ELLNODE *pStartNode, ELLNODE *pEndNode, ELLLIST *pDstList);
143 LIBCOM_API ELLNODE * ellGet (ELLLIST *pList);
149 LIBCOM_API ELLNODE * ellPop (ELLLIST *pList);
157 LIBCOM_API void ellInsert (ELLLIST *plist, ELLNODE *pPrev, ELLNODE *pNode);
166 LIBCOM_API ELLNODE * ellNth (ELLLIST *pList, int nodeNum);
174 LIBCOM_API ELLNODE * ellNStep (ELLNODE *pNode, int nStep);
182 LIBCOM_API int ellFind (ELLLIST *pList, ELLNODE *pNode);
183 
184 typedef int (*pListCmp)(const ELLNODE* A, const ELLNODE* B);
195 LIBCOM_API void ellSortStable(ELLLIST *pList, pListCmp pListCmp);
206 LIBCOM_API void ellFree2 (ELLLIST *pList, FREEFUNC freeFunc);
211 LIBCOM_API void ellVerify (ELLLIST *pList);
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif /* INC_ellLib_H */
LIBCOM_API ELLNODE * ellPop(ELLLIST *pList)
Deletes and returns the last node from a list.
Definition: ellLib.c:162
LIBCOM_API void ellVerify(ELLLIST *pList)
Verifies that the list is consistent.
Definition: ellLib.c:304
LIBCOM_API void ellSortStable(ELLLIST *pList, pListCmp pListCmp)
Stable (MergeSort) of a given list.
Definition: ellSort.c:30
LIBCOM_API void ellAdd(ELLLIST *pList, ELLNODE *pNode)
Adds a node to the end of a list.
Definition: ellLib.c:24
LIBCOM_API void ellInsert(ELLLIST *plist, ELLNODE *pPrev, ELLNODE *pNode)
Inserts a node into a list immediately after a specific node.
Definition: ellLib.c:178
struct ELLLIST ELLLIST
List header type.
LIBCOM_API void ellDelete(ELLLIST *pList, ELLNODE *pNode)
Deletes a node from a list.
Definition: ellLib.c:75
void(* FREEFUNC)(void *)
Pointer to free() for use by ellFree() macro.
Definition: ellLib.h:71
List node type.
Definition: ellLib.h:45
LIBCOM_API ELLNODE * ellGet(ELLLIST *pList)
Deletes and returns the first node from a list.
Definition: ellLib.c:147
struct ELLNODE * previous
Pointer to previous node in list.
Definition: ellLib.h:47
struct ELLNODE * next
Pointer to next node in list.
Definition: ellLib.h:46
LIBCOM_API ELLNODE * ellNStep(ELLNODE *pNode, int nStep)
Find the list node nStep steps away from a specified node.
Definition: ellLib.c:237
LIBCOM_API void ellFree2(ELLLIST *pList, FREEFUNC freeFunc)
Free all the nodes in a list.
Definition: ellLib.c:282
int count
Number of nodes on the list.
Definition: ellLib.h:58
LIBCOM_API ELLNODE * ellNth(ELLLIST *pList, int nodeNum)
Find the Nth node in a list.
Definition: ellLib.c:205
LIBCOM_API int ellFind(ELLLIST *pList, ELLNODE *pNode)
Find the index of a specific node in a list.
Definition: ellLib.c:258
List header type.
Definition: ellLib.h:56
ELLNODE node
Pointers to the first and last nodes on list.
Definition: ellLib.h:57
LIBCOM_API void ellConcat(ELLLIST *pDstList, ELLLIST *pAddList)
Concatenates a list to the end of another list. The list to be added is left empty. Either list (or both) can be empty at the beginning of the operation.
Definition: ellLib.c:46
struct ELLNODE ELLNODE
List node type.
LIBCOM_API void ellExtract(ELLLIST *pSrcList, ELLNODE *pStartNode, ELLNODE *pEndNode, ELLLIST *pDstList)
Extract a sublist from a list.
Definition: ellLib.c:101
int(* pListCmp)(const ELLNODE *A, const ELLNODE *B)
Definition: ellLib.h:184