-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.h
More file actions
42 lines (28 loc) · 734 Bytes
/
list.h
File metadata and controls
42 lines (28 loc) · 734 Bytes
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
/*
* Implements a doubly-linked list
* Found in the book "Learn C the Hard Way" by Zed Shaw
*/
#pragma once
struct Node {
void *data;
struct Node *next;
struct Node *prev;
};
typedef struct {
struct Node *first;
struct Node *last;
int length;
} List;
List *List_create();
void List_init(List* list);
void List_clear(List *list);
void List_destroy(List *list);
void List_push(List *list, void *data);
void *List_pop(List *list);
void *List_pop(List *list);
void List_queue(List *list, void *data);
void *List_dequeue(List *list);
void List_print(List *list);
#define LIST_FOREACH(L, S, M, V) struct Node *_node = NULL;\
struct Node *V = NULL;\
for(V = _node = L->S; _node != NULL; V = _node = _node->M)