-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.h
37 lines (28 loc) · 909 Bytes
/
list.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
#ifndef __LIST_H
#define __LIST_H
// a common function used to free malloc'd objects
typedef void (*freeFunction)(void *);
typedef enum { FALSE, TRUE } bool;
typedef bool (*ListIterator)(void *);
typedef struct _listNode {
void *data;
struct _listNode *next;
struct _listNode *prev;
} ListNode;
typedef struct {
int logicalLength;
int elementSize;
ListNode *head;
ListNode *tail;
freeFunction freeFn;
} List;
void list_new(List *list, int elementSize, freeFunction freeFn);
void list_destroy(List *list);
void list_prepend(List *list, void *element);
void list_append(List *list, void *element);
void list_del_node(List *list, ListNode *node);
int list_size(List *list);
void list_for_each(List *list, ListIterator iterator);
void list_head(List *list, void *element, bool removeFromList);
void list_tail(List *list, void *element);
#endif