aboutsummaryrefslogtreecommitdiff
path: root/list/include/list.h
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2021-12-04 16:01:12 -0800
committer3gg <3gg@shellblade.net>2021-12-04 16:01:12 -0800
commitf8217d240d598f39f70047f7a623dd46312542c6 (patch)
tree4e40843d665e388416c1226f739c2b8c0b8da736 /list/include/list.h
parent5f6ea503cdb6ad4a95b679672a1ad324d96c89a5 (diff)
Initial commit.
Diffstat (limited to 'list/include/list.h')
-rw-r--r--list/include/list.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/list/include/list.h b/list/include/list.h
new file mode 100644
index 0000000..b00b48b
--- /dev/null
+++ b/list/include/list.h
@@ -0,0 +1,21 @@
1/// A doubly linked list.
2///
3/// This list does not hold user data. Instead, the list can be used as an
4/// intrusive list or as part as a more complex data structure.
5#pragma once
6
7#include <stddef.h>
8
9typedef struct list list;
10
11typedef struct list {
12 list* prev;
13 list* next;
14} list;
15
16/// Create a new list from an array of `size` items.
17void list_make(list* list, size_t size);
18
19/// Iterates over all the items in the list.
20#define list_foreach(LIST, iter) \
21 for (struct list* iter = LIST; iter; iter = iter->next)