diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2022-07-26 18:16:18 -0300 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2022-07-26 18:16:18 -0300 |
commit | e108eea9d5b6846a9c1e227db1bcb4e15aebaab1 (patch) | |
tree | b79fe0dfbf4ddb5ed8db1a60c1dbe22b496e42f7 /linked_list.h | |
parent | b0470f2db735f4dffda742fe38a7f9488a5ebc08 (diff) |
linked_list: Add `linked_list` type.
This is a type generic doubly linked list implementation.
I used the implementation from DevkitPro's libnds library as a baseline.
Link to libnds implementation:
https://github.com/devkitPro/libnds/blob/master/source/arm9/linkedlist.c
Diffstat (limited to 'linked_list.h')
-rw-r--r-- | linked_list.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/linked_list.h b/linked_list.h new file mode 100644 index 0000000..643e4f2 --- /dev/null +++ b/linked_list.h @@ -0,0 +1,18 @@ +#ifndef LINKED_LIST_H +#define LINKED_LIST_H + +typedef struct linked_list linked_list; + +struct linked_list { + linked_list *next; /* Next node in the list. */ + linked_list *prev; /* Previous node in the list. */ + void *data; /* Pointer to data. */ +}; + +extern linked_list *add_node(linked_list **tail, void *data); +extern void remove_node(linked_list *node); +extern linked_list *get_head(linked_list *node); +extern linked_list *get_tail(linked_list *node); +extern int linked_list_size(linked_list *tail); + +#endif |