#include <stdlib.h>
#include "epicsAssert.h"
#include "ellLib.h"
Go to the source code of this file.
|
void | ellAdd (ELLLIST *pList, ELLNODE *pNode) |
| Adds a node to the end of a list. More...
|
|
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. More...
|
|
void | ellDelete (ELLLIST *pList, ELLNODE *pNode) |
| Deletes a node from a list. More...
|
|
void | ellExtract (ELLLIST *pSrcList, ELLNODE *pStartNode, ELLNODE *pEndNode, ELLLIST *pDstList) |
| Extract a sublist from a list. More...
|
|
ELLNODE * | ellGet (ELLLIST *pList) |
| Deletes and returns the first node from a list. More...
|
|
ELLNODE * | ellPop (ELLLIST *pList) |
| Deletes and returns the last node from a list. More...
|
|
void | ellInsert (ELLLIST *plist, ELLNODE *pPrev, ELLNODE *pNode) |
| Inserts a node into a list immediately after a specific node. More...
|
|
ELLNODE * | ellNth (ELLLIST *pList, int nodeNum) |
| Find the Nth node in a list. More...
|
|
ELLNODE * | ellNStep (ELLNODE *pNode, int nStep) |
| Find the list node nStep steps away from a specified node. More...
|
|
int | ellFind (ELLLIST *pList, ELLNODE *pNode) |
| Find the index of a specific node in a list. More...
|
|
void | ellFree2 (ELLLIST *pList, FREEFUNC freeFunc) |
| Free all the nodes in a list. More...
|
|
void | ellVerify (ELLLIST *pList) |
| Verifies that the list is consistent. More...
|
|
Adds a node to the end of a list.
- Parameters
-
pList | Pointer to list descriptor |
pNode | Pointer to node to be added |
Definition at line 24 of file ellLib.c.
struct ELLNODE * previous
Pointer to previous node in list.
struct ELLNODE * next
Pointer to next node in list.
int count
Number of nodes on the list.
ELLNODE node
Pointers to the first and last nodes on list.
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.
- Parameters
-
pDstList | Destination list |
pAddList | List to be added to pDstList |
Definition at line 46 of file ellLib.c.
48 if (pAddList->
count == 0)
51 if (pDstList->
count == 0) {
struct ELLNODE * previous
Pointer to previous node in list.
struct ELLNODE * next
Pointer to next node in list.
int count
Number of nodes on the list.
ELLNODE node
Pointers to the first and last nodes on list.
Deletes a node from a list.
- Parameters
-
pList | Pointer to list descriptor |
pNode | Pointer to node to be deleted |
Definition at line 75 of file ellLib.c.
struct ELLNODE * previous
Pointer to previous node in list.
struct ELLNODE * next
Pointer to next node in list.
int count
Number of nodes on the list.
ELLNODE node
Pointers to the first and last nodes on list.
Extract a sublist from a list.
- Parameters
-
pSrcList | Pointer to source list |
pStartNode | First node in pSrcList to be extracted |
pEndNode | Last node in pSrcList to be extracted |
pDstList | Pointer to list where to put extracted list |
Definition at line 101 of file ellLib.c.
131 while(pnode != pEndNode)
136 pSrcList->
count -= count;
137 pDstList->
count += count;
struct ELLNODE * previous
Pointer to previous node in list.
struct ELLNODE * next
Pointer to next node in list.
int count
Number of nodes on the list.
ELLNODE node
Pointers to the first and last nodes on list.
Find the index of a specific node in a list.
- Parameters
-
pList | Pointer to list to search |
pNode | Pointer to node to search for |
- Returns
- The node's index, or -1 if it cannot be found on the list.
- Note
- The first node has index 1.
Definition at line 258 of file ellLib.c.
263 while ((got != pNode) && (got !=
NULL)) {
struct ELLNODE * next
Pointer to next node in list.
ELLNODE node
Pointers to the first and last nodes on list.
Free all the nodes in a list.
This routine empties a list, calling freeFunc() for every node on it.
- Parameters
-
pList | List from which to free all nodes |
freeFunc | The free() routine to be called |
- Note
- The nodes in the list are free()'d on the assumption that the node structures were malloc()'d one-at-a-time and that the ELLNODE structure is the first member of the parent structure.
Definition at line 282 of file ellLib.c.
287 while (nnode !=
NULL)
struct ELLNODE * previous
Pointer to previous node in list.
struct ELLNODE * next
Pointer to next node in list.
int count
Number of nodes on the list.
ELLNODE node
Pointers to the first and last nodes on list.
Deletes and returns the first node from a list.
- Parameters
-
pList | Pointer to list from which to get node |
- Returns
- Pointer to the first node from the list, or NULL if the list is empty
Definition at line 147 of file ellLib.c.
struct ELLNODE * next
Pointer to next node in list.
void ellDelete(ELLLIST *pList, ELLNODE *pNode)
Deletes a node from a list.
ELLNODE node
Pointers to the first and last nodes on list.
Inserts a node into a list immediately after a specific node.
- Parameters
-
plist | Pointer to list into which to insert node |
pPrev | Pointer to the node after which to insert |
pNode | Pointer to the node to be inserted |
- Note
- If
pPrev
is NULL pNode
will be inserted at the head of the list
Definition at line 178 of file ellLib.c.
struct ELLNODE * previous
Pointer to previous node in list.
struct ELLNODE * next
Pointer to next node in list.
int count
Number of nodes on the list.
ELLNODE node
Pointers to the first and last nodes on list.
Find the list node nStep
steps away from a specified node.
- Parameters
-
pNode | The known node |
nStep | How many steps to take, may be negative to step backwards |
- Returns
- Pointer to the node
nStep
nodes from pNode
, or NULL if there is no such node in the list.
Definition at line 237 of file ellLib.c.
240 while ((pNode !=
NULL) && nStep) {
245 while ((pNode !=
NULL) && nStep) {
struct ELLNODE * previous
Pointer to previous node in list.
struct ELLNODE * next
Pointer to next node in list.
Find the Nth node in a list.
- Parameters
-
pList | Pointer to list from which to find node |
nodeNum | Index of the node to be found |
- Returns
- Pointer to the element at index
nodeNum
in pList, or NULL if there is no such node in the list.
- Note
- The first node has index 1.
Definition at line 205 of file ellLib.c.
209 if ((nodeNum < 1) || (pList->
count == 0))
212 if (nodeNum > pList->
count/2) {
213 if (nodeNum > pList->
count)
217 nodeNum = pList->
count - nodeNum;
226 while (--nodeNum > 0)
struct ELLNODE * previous
Pointer to previous node in list.
struct ELLNODE * next
Pointer to next node in list.
int count
Number of nodes on the list.
ELLNODE node
Pointers to the first and last nodes on list.
Deletes and returns the last node from a list.
- Parameters
-
pList | Pointer to list from which to get node |
- Returns
- Pointer to the last node from the list, or NULL if the list is empty
Definition at line 162 of file ellLib.c.
struct ELLNODE * previous
Pointer to previous node in list.
void ellDelete(ELLLIST *pList, ELLNODE *pNode)
Deletes a node from a list.
ELLNODE node
Pointers to the first and last nodes on list.
Verifies that the list is consistent.
- Parameters
-
Definition at line 304 of file ellLib.c.
#define assert(exp)
Declare that a condition should be true.
#define ellCount(PLIST)
Report the number of nodes in a list.
#define ellPrevious(PNODE)
Find the previous node in list.
#define ellNext(PNODE)
Find the next node in list.
#define ellLast(PLIST)
Find the last node in list.
#define ellFirst(PLIST)
Find the first node in list.