EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 * SPDX-License-Identifier: EPICS
7 * EPICS BASE is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
27 #ifndef INC_ellLib_H
28 #define INC_ellLib_H
29 
30 #include "libComAPI.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
46 typedef struct ELLNODE {
47  struct ELLNODE *next;
48  struct ELLNODE *previous;
49 } ELLNODE;
50 
53 #define ELLNODE_INIT {NULL, NULL}
54 
57 typedef struct ELLLIST {
59  int count;
60 } ELLLIST;
61 
64 #define ELLLIST_INIT {ELLNODE_INIT, 0}
65 
72 typedef void (*FREEFUNC)(void *);
73 
77 #define ellInit(PLIST) {\
78  (PLIST)->node.next = (PLIST)->node.previous = NULL;\
79  (PLIST)->count = 0;\
80 }
81 
85 #define ellCount(PLIST) ((PLIST)->count)
86 
90 #define ellFirst(PLIST) ((PLIST)->node.next)
91 
95 #define ellLast(PLIST) ((PLIST)->node.previous)
96 
100 #define ellNext(PNODE) ((PNODE)->next)
101 
105 #define ellPrevious(PNODE) ((PNODE)->previous)
106 
109 #define ellFree(PLIST) ellFree2(PLIST, free)
110 
116 LIBCOM_API void ellAdd (ELLLIST *pList, ELLNODE *pNode);
124 LIBCOM_API void ellConcat (ELLLIST *pDstList, ELLLIST *pAddList);
130 LIBCOM_API void ellDelete (ELLLIST *pList, ELLNODE *pNode);
138 LIBCOM_API void ellExtract (ELLLIST *pSrcList, ELLNODE *pStartNode, ELLNODE *pEndNode, ELLLIST *pDstList);
144 LIBCOM_API ELLNODE * ellGet (ELLLIST *pList);
150 LIBCOM_API ELLNODE * ellPop (ELLLIST *pList);
158 LIBCOM_API void ellInsert (ELLLIST *plist, ELLNODE *pPrev, ELLNODE *pNode);
167 LIBCOM_API ELLNODE * ellNth (ELLLIST *pList, int nodeNum);
175 LIBCOM_API ELLNODE * ellNStep (ELLNODE *pNode, int nStep);
183 LIBCOM_API int ellFind (ELLLIST *pList, ELLNODE *pNode);
184 
185 typedef int (*pListCmp)(const ELLNODE* A, const ELLNODE* B);
196 LIBCOM_API void ellSortStable(ELLLIST *pList, pListCmp pListCmp);
207 LIBCOM_API void ellFree2 (ELLLIST *pList, FREEFUNC freeFunc);
212 LIBCOM_API void ellVerify (ELLLIST *pList);
213 
214 #ifdef __cplusplus
215 }
216 #endif
217 
218 #endif /* INC_ellLib_H */
struct ELLNODE * previous
Pointer to previous node in list.
Definition: ellLib.h:48
LIBCOM_API ELLNODE * ellPop(ELLLIST *pList)
Deletes and returns the last node from a list.
LIBCOM_API ELLNODE * ellGet(ELLLIST *pList)
Deletes and returns the first node from a list.
List node type.
Definition: ellLib.h:46
ELLNODE node
Pointers to the first and last nodes on list.
Definition: ellLib.h:58
int count
Number of nodes on the list.
Definition: ellLib.h:59
LIBCOM_API int ellFind(ELLLIST *pList, ELLNODE *pNode)
Find the index of a specific node in a list.
LIBCOM_API void ellExtract(ELLLIST *pSrcList, ELLNODE *pStartNode, ELLNODE *pEndNode, ELLLIST *pDstList)
Extract a sublist from a list.
List header type.
Definition: ellLib.h:57
LIBCOM_API void ellAdd(ELLLIST *pList, ELLNODE *pNode)
Adds a node to the end of a list.
LIBCOM_API void ellVerify(ELLLIST *pList)
Verifies that the list is consistent.
LIBCOM_API void ellSortStable(ELLLIST *pList, pListCmp pListCmp)
Stable (MergeSort) of a given list.
LIBCOM_API ELLNODE * ellNth(ELLLIST *pList, int nodeNum)
Find the Nth node in a list.
void(* FREEFUNC)(void *)
Pointer to free() for use by ellFree() macro.
Definition: ellLib.h:72
LIBCOM_API void ellInsert(ELLLIST *plist, ELLNODE *pPrev, ELLNODE *pNode)
Inserts a node into a list immediately after a specific node.
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.
LIBCOM_API ELLNODE * ellNStep(ELLNODE *pNode, int nStep)
Find the list node nStep steps away from a specified node.
LIBCOM_API void ellFree2(ELLLIST *pList, FREEFUNC freeFunc)
Free all the nodes in a list.
struct ELLNODE * next
Pointer to next node in list.
Definition: ellLib.h:47
LIBCOM_API void ellDelete(ELLLIST *pList, ELLNODE *pNode)
Deletes a node from a list.