diff options
author | Malfurious <m@lfurio.us> | 2023-07-07 20:08:13 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2023-07-08 11:05:07 -0400 |
commit | c29bf2efbdc4f4186f3fe571601b4d1acac4b321 (patch) | |
tree | f5a23bda3a58794679ec4ed6eb1ba7a95249954e /list.h | |
parent | 415c553d96c4851350512cc943e10ec477427e02 (diff) | |
download | misplays-c29bf2efbdc4f4186f3fe571601b4d1acac4b321.tar.gz misplays-c29bf2efbdc4f4186f3fe571601b4d1acac4b321.zip |
Implement trivial linked list
* Bring-your-own-node (generic / zero allocations)
* Doubly-linked and circular, forward and backward traversable
* Random insert/removal in constant time
* All operations are no-fail
* [Some type safety concessions though]
Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to '')
-rw-r--r-- | list.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -0,0 +1,10 @@ +#pragma once +#define LINKEDLIST void *prev, *next + +struct list { + void *tail, *head, *end; +}; + +extern void list_init(struct list *list); +extern void list_insert(void *_next, void *_node); +extern void list_remove(void *_node); |