docs/Writerside/topics/linked_list.h.md

Thu, 23 Jan 2025 20:19:03 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 23 Jan 2025 20:19:03 +0100
branch
docs/3.1
changeset 1142
9437530176bc
parent 1141
a06a2d27c043
child 1143
0559812df10c
permissions
-rw-r--r--

add symbols that need documentation as TODOs

relates to #451

# linked_list.h

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

mercurial