docs/Writerside/topics/linked_list.h.md

Sat, 25 Jan 2025 13:44:24 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 25 Jan 2025 13:44:24 +0100
branch
docs/3.1
changeset 1146
151c057faf7c
parent 1143
0559812df10c
permissions
-rw-r--r--

add marker to every incomplete page

relates to #451

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

mercurial