-
Notifications
You must be signed in to change notification settings - Fork 12
/
dlList.h
61 lines (54 loc) · 1.59 KB
/
dlList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* dlList.h
*
* Created on: Nov 17, 2013
* Author: poppe
*/
#ifndef DLLIST_H_
#define DLLIST_H_
#include "rtthread.h"
/*** STUCTURES ENUMS and UNIONS ***/
enum dllTypes
{
DLL_FIFO,
DLL_FIL0,
};
struct Node
{
struct Node *next;
struct Node *prev;
void * data;
};
struct List
{
int type;
int len;
struct Node *current;
struct Node *first;
struct Node *last;
};
/*** TYPEDEFS ***/
typedef struct Node Node_t;
typedef struct List List_t;
/*** DEFINES ***/
#define DLL_MALLOC(size) rt_malloc(size);
#define DLL_FREE(data) rt_free(data);
/*** PROTOTYPES ***/
int dllist_initList(List_t *list, int type);
int dllist_newNode(Node_t **node);
int dllist_destryNode(Node_t *node);
Node_t * dllist_getNodeAt(List_t *list, int pos);
void * dllist_getDataAt(List_t *list, int pos);
Node_t *dllist_addData(List_t *list, void *data);
int dllist_addNode(List_t *list, Node_t *node);
int dllist_insertBefore(List_t *list, Node_t *node, Node_t *newNode);
int dllist_addNodeToEnd(List_t *list, Node_t *node);
int dllist_addNodeToFront(List_t *list, Node_t *node);
int dllist_removeNode(List_t *list, Node_t *node, int freeNode);
int dllist_listLen(List_t *list);
//void dllist_foreachNode(List_t *list, int (*prototype(void *, void *)), void *arg)
int dllist_findData(List_t list, void *data, int (*prototype(void *first, void *second)));
int dllist_NodeExsist(List_t *list, Node_t *node);
void *dllist_searchWithinData(List_t * list, int(*prototype(void *, void*)), void *arg);
void dllist_foreachNode(List_t *list, void(*prototype)(Node_t *node, void *arg), void *arg);
#endif /* DLLIST_H_ */