diff -r 0f70bb04f7ba -r b0300de92b72 docs/Writerside/topics/linked_list.h.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/Writerside/topics/linked_list.h.md Tue Feb 11 19:55:32 2025 +0100 @@ -0,0 +1,53 @@ +# Linked List + + +Outdated - Rewrite! + + +On top of implementing the list interface, this header also defines several low-level functions that +work with arbitrary structures. +Low-level functions, in contrast to the high-level list interface, can easily be recognized by their snake-casing. +The function `cx_linked_list_at`, for example, implements a similar functionality like `cxListAt`, but operates +on arbitrary structures. +The following snippet shows how it is used. +All other low-level functions work similarly. +```c +struct node { + node *next; + node *prev; + int data; +}; + +const ptrdiff_t loc_prev = offsetof(struct node, prev); +const ptrdiff_t loc_next = offsetof(struct node, next); +const ptrdiff_t loc_data = offsetof(struct node, data); + +struct node a = {0}, b = {0}, c = {0}, d = {0}; +cx_linked_list_link(&a, &b, loc_prev, loc_next); +cx_linked_list_link(&b, &c, loc_prev, loc_next); +cx_linked_list_link(&c, &d, loc_prev, loc_next); + +cx_linked_list_at(&a, 0, loc_next, 2); // returns pointer to c +``` + +## Undocumented Symbols (TODO) +### cx_linked_list_add +### cx_linked_list_at +### cx_linked_list_compare +### cxLinkedListCreate +### cx_linked_list_find +### cx_linked_list_find_node +### cx_linked_list_first +### cx_linked_list_insert +### cx_linked_list_insert_chain +### cx_linked_list_insert_sorted +### cx_linked_list_insert_sorted_chain +### cx_linked_list_last +### cx_linked_list_link +### cx_linked_list_prepend +### cx_linked_list_prev +### cx_linked_list_remove_chain +### cx_linked_list_reverse +### cx_linked_list_size +### cx_linked_list_sort +### cx_linked_list_unlink