| |
1 # Linked List |
| |
2 |
| |
3 <warning> |
| |
4 Outdated - Rewrite! |
| |
5 </warning> |
| |
6 |
| |
7 On top of implementing the list interface, this header also defines several low-level functions that |
| |
8 work with arbitrary structures. |
| |
9 Low-level functions, in contrast to the high-level list interface, can easily be recognized by their snake-casing. |
| |
10 The function `cx_linked_list_at`, for example, implements a similar functionality like `cxListAt`, but operates |
| |
11 on arbitrary structures. |
| |
12 The following snippet shows how it is used. |
| |
13 All other low-level functions work similarly. |
| |
14 ```c |
| |
15 struct node { |
| |
16 node *next; |
| |
17 node *prev; |
| |
18 int data; |
| |
19 }; |
| |
20 |
| |
21 const ptrdiff_t loc_prev = offsetof(struct node, prev); |
| |
22 const ptrdiff_t loc_next = offsetof(struct node, next); |
| |
23 const ptrdiff_t loc_data = offsetof(struct node, data); |
| |
24 |
| |
25 struct node a = {0}, b = {0}, c = {0}, d = {0}; |
| |
26 cx_linked_list_link(&a, &b, loc_prev, loc_next); |
| |
27 cx_linked_list_link(&b, &c, loc_prev, loc_next); |
| |
28 cx_linked_list_link(&c, &d, loc_prev, loc_next); |
| |
29 |
| |
30 cx_linked_list_at(&a, 0, loc_next, 2); // returns pointer to c |
| |
31 ``` |
| |
32 |
| |
33 ## Undocumented Symbols (TODO) |
| |
34 ### cx_linked_list_add |
| |
35 ### cx_linked_list_at |
| |
36 ### cx_linked_list_compare |
| |
37 ### cxLinkedListCreate |
| |
38 ### cx_linked_list_find |
| |
39 ### cx_linked_list_find_node |
| |
40 ### cx_linked_list_first |
| |
41 ### cx_linked_list_insert |
| |
42 ### cx_linked_list_insert_chain |
| |
43 ### cx_linked_list_insert_sorted |
| |
44 ### cx_linked_list_insert_sorted_chain |
| |
45 ### cx_linked_list_last |
| |
46 ### cx_linked_list_link |
| |
47 ### cx_linked_list_prepend |
| |
48 ### cx_linked_list_prev |
| |
49 ### cx_linked_list_remove_chain |
| |
50 ### cx_linked_list_reverse |
| |
51 ### cx_linked_list_size |
| |
52 ### cx_linked_list_sort |
| |
53 ### cx_linked_list_unlink |