docs/Writerside/topics/list.h.md

Tue, 04 Mar 2025 18:20:36 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 04 Mar 2025 18:20:36 +0100
changeset 1237
5cba456aff67
parent 1236
f392f27a1dc6
permissions
-rw-r--r--

add structure to list documentation

relates to #451

1143
0559812df10c assign proper names to the documentation topics
Mike Becker <universe@uap-core.de>
parents: 1142
diff changeset
1 # List Interface
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>
1190
a7b913d5d589 bring incomplete docs into a shape that can be released
Mike Becker <universe@uap-core.de>
parents: 1146
diff changeset
4 Outdated Section - will be updated soon!
1146
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
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
7 The `list.h` header defines a common interface for all list implementations.
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
8
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
9 UCX already comes with two common list implementations ([linked list](linked_list.h.md) and [array list](array_list.h.md))
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
10 that should cover most use cases.
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
11 But if you feel the need to implement an own list, you will find instructions [below](#implement-own-list-structures).
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
12
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
13 ## Example
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
14
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
15 <warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
16 TODO: add example how to work with lists
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
17 </warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
18
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
19 > If you want to lazy-initialize lists, you can use the global `cxEmptyList` symbol as a placeholder instead of using a `NULL`-pointer.
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
20 > While you *must not* insert items into that list, you can safely access this list or create iterators.
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
21 > This allows you to write clean code without checking for `NULL`-pointer everywhere.
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
22 > You still need to make sure that the placeholder is replaced with an actual list before inserting items.
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
23
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
24 ## Insert
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
25
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
26 ```C
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
27 int cxListAdd(CxList *list, const void *elem);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
28
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
29 size_t cxListAddArray(CxList *list, const void *array, size_t n);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
30
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
31 int cxListInsert(CxList *list, size_t index, const void *elem);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
32
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
33 int cxListInsertSorted(CxList *list, const void *elem);
1141
a06a2d27c043 create new page structure
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
35 size_t cxListInsertArray(CxList *list, size_t index,
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
36 const void *array, size_t n);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
37
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
38 size_t cxListInsertSortedArray(CxList *list,
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
39 const void *array, size_t n);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
40
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
41 int cxListInsertAfter(CxIterator *iter, const void *elem);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
42
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
43 int cxListInsertBefore(CxIterator *iter, const void *elem);
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
44 ```
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
45
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
46 <warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
47 TODO: add documentation
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
48 </warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
49
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
50 ## Access and Find
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
51
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
52 ```C
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
53 size_t cxListSize(const CxList *list);
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
54
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
55 void *cxListAt(const CxList *list, size_t index);
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
56
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
57 size_t cxListFind(const CxList *list, const void *elem);
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
58
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
59 size_t cxListFindRemove(CxList *list, const void *elem);
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
60
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
61 bool cxListIndexValid(const CxList *list, size_t index);
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
62 ```
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
63
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
64 <warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
65 TODO: add documentation
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
66 </warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
67
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
68 ## Remove
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
69
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
70 ```C
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
71 int cxListRemove(CxList *list, size_t index);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
72
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
73 int cxListRemoveAndGet(CxList *list, size_t index, void *targetbuf);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
74
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
75 size_t cxListRemoveArray(CxList *list, size_t index, size_t num);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
76
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
77 size_t cxListRemoveArrayAndGet(CxList *list, size_t index, size_t num,
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
78 void *targetbuf);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
79
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
80 void cxListClear(CxList *list);
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
81 ```
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
82
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
83 <warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
84 TODO: add documentation
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
85 </warning>
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
86
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
87 ## Iterators
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
88
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
89 ```C
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
90 CxIterator cxListIterator(const CxList *list);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
91
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
92 CxIterator cxListMutIterator(CxList *list);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
93
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
94 CxIterator cxListBackwardsIterator(const CxList *list);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
95
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
96 CxIterator cxListMutBackwardsIterator(CxList *list);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
97
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
98 CxIterator cxListIteratorAt(const CxList *list, size_t index);
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
99
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
100 CxIterator cxListBackwardsIteratorAt(const CxList *list, size_t index);
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
101
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
102 CxIterator cxListMutIteratorAt(CxList *list, size_t index);
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
103
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
104 CxIterator cxListMutBackwardsIteratorAt(CxList *list, size_t index);
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
105 ```
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
106
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
107 <warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
108 TODO: add documentation
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
109 </warning>
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
110
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
111 ## Reorder
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
112
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
113 ```C
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
114 int cxListSwap(CxList *list, size_t i, size_t j);
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
115
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
116 void cxListSort(CxList *list);
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
117
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
118 void cxListReverse(CxList *list);
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
119 ```
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
120
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
121 <warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
122 TODO: add documentation
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
123 </warning>
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
124
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
125 ## Compare
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
126
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
127 ```C
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
128 int cxListCompare(const CxList *list, const CxList *other);
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
129 ```
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
130
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
131 <warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
132 TODO: add documentation
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
133 </warning>
1236
f392f27a1dc6 list all function from list.h that need to be documented
Mike Becker <universe@uap-core.de>
parents: 1190
diff changeset
134
1237
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
135 ## Dispose
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
136
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
137 ```C
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
138 void cxListFree(CxList *list);
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
139 ```
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
140
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
141 <warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
142 TODO: add documentation
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
143 </warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
144
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
145 ## Implement own List Structures
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
146
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
147 <warning>
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
148 TODO: add documentation
5cba456aff67 add structure to list documentation
Mike Becker <universe@uap-core.de>
parents: 1236
diff changeset
149 </warning>
1142
9437530176bc add symbols that need documentation as TODOs
Mike Becker <universe@uap-core.de>
parents: 1141
diff changeset
150
1190
a7b913d5d589 bring incomplete docs into a shape that can be released
Mike Becker <universe@uap-core.de>
parents: 1146
diff changeset
151 <seealso>
a7b913d5d589 bring incomplete docs into a shape that can be released
Mike Becker <universe@uap-core.de>
parents: 1146
diff changeset
152 <category ref="apidoc">
a7b913d5d589 bring incomplete docs into a shape that can be released
Mike Becker <universe@uap-core.de>
parents: 1146
diff changeset
153 <a href="https://ucx.sourceforge.io/api/list_8h.html">list.h</a>
a7b913d5d589 bring incomplete docs into a shape that can be released
Mike Becker <universe@uap-core.de>
parents: 1146
diff changeset
154 </category>
a7b913d5d589 bring incomplete docs into a shape that can be released
Mike Becker <universe@uap-core.de>
parents: 1146
diff changeset
155 </seealso>

mercurial