-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.h
51 lines (40 loc) · 1.12 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* File: list.h
* Author: prakbans
*
* Created on September 21, 2014, 10:39 AM
*/
#ifndef LIST_H
#define LIST_H
#ifdef __cplusplus
extern "C" {
#endif
// a common function used to free malloc'd objects
typedef void (*freeFunction)(void *);
typedef enum {
FALSE, TRUE
} boolean;
typedef boolean(*listIterator)(void *);
typedef struct _listNode {
void *data;
struct _listNode *next;
} 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);
int list_size(list *list);
void list_for_each(list *list, listIterator iterator);
void list_head(list *list, void *element, boolean removeFromList);
void list_tail(list *list, void *element);
#ifdef __cplusplus
}
#endif
#endif /* LIST_H */