2 |
2 |
3 <warning> |
3 <warning> |
4 Outdated Section - will be updated soon! |
4 Outdated Section - will be updated soon! |
5 </warning> |
5 </warning> |
6 |
6 |
7 This header defines a common interface for all list implementations. |
7 The `list.h` header defines a common interface for all list implementations. |
8 |
8 |
9 UCX already comes with two common list implementations (linked list and array list) that should cover most use cases. |
9 UCX already comes with two common list implementations ([linked list](linked_list.h.md) and [array list](array_list.h.md)) |
10 But if you feel the need to implement an own list, the only thing you need to do is to define a struct with a |
10 that should cover most use cases. |
11 `struct cx_list_s` as first member, and set an appropriate list class that implements the functionality. |
11 But if you feel the need to implement an own list, you will find instructions [below](#implementing-own-list-structures). |
12 It is strongly recommended that this class is shared among all instances of the same list type, because otherwise |
|
13 the `cxListCompare` function cannot use the optimized implementation of your class and will instead fall back to |
|
14 using iterators to compare the contents element-wise. |
|
15 |
12 |
16 <!-- |
13 ## Overview |
17 ## Undocumented Symbols (TODO) |
14 |
18 ### cx_empty_list |
15 ```C |
19 ### cxEmptyList |
16 size_t cxListSize(const CxList *list); |
20 ### cxListCompare |
17 |
21 ### cx_list_default_insert_array |
18 int cxListAdd(CxList *list, const void *elem); |
22 ### cx_list_default_insert_sorted |
19 |
23 ### cx_list_default_sort |
20 size_t cxListAddArray(CxList *list, const void *array, size_t n); |
24 ### cx_list_default_swap |
21 |
25 ### cxListFree |
22 int cxListInsert(CxList *list, size_t index, const void *elem); |
26 ### cx_list_init |
23 |
27 ### cxListMutBackwardsIteratorAt |
24 int cxListInsertSorted(CxList *list, const void *elem); |
28 ### cxListMutIteratorAt |
25 |
29 --> |
26 size_t cxListInsertArray(CxList *list, size_t index, |
|
27 const void *array, size_t n); |
|
28 |
|
29 size_t cxListInsertSortedArray(CxList *list, |
|
30 const void *array, size_t n); |
|
31 |
|
32 int cxListInsertAfter(CxIterator *iter, const void *elem); |
|
33 |
|
34 int cxListInsertBefore(CxIterator *iter, const void *elem); |
|
35 |
|
36 int cxListRemove(CxList *list, size_t index); |
|
37 |
|
38 int cxListRemoveAndGet(CxList *list, size_t index, void *targetbuf); |
|
39 |
|
40 size_t cxListRemoveArray(CxList *list, size_t index, size_t num); |
|
41 |
|
42 size_t cxListRemoveArrayAndGet(CxList *list, size_t index, size_t num, |
|
43 void *targetbuf); |
|
44 |
|
45 void cxListClear(CxList *list); |
|
46 |
|
47 int cxListSwap(CxList *list, size_t i, size_t j); |
|
48 |
|
49 void *cxListAt(const CxList *list, size_t index); |
|
50 |
|
51 CxIterator cxListIteratorAt(const CxList *list, size_t index); |
|
52 |
|
53 CxIterator cxListBackwardsIteratorAt(const CxList *list, size_t index); |
|
54 |
|
55 CxIterator cxListMutIteratorAt(CxList *list, size_t index); |
|
56 |
|
57 CxIterator cxListMutBackwardsIteratorAt(CxList *list, size_t index); |
|
58 |
|
59 CxIterator cxListIterator(const CxList *list); |
|
60 |
|
61 CxIterator cxListMutIterator(CxList *list); |
|
62 |
|
63 CxIterator cxListBackwardsIterator(const CxList *list); |
|
64 |
|
65 CxIterator cxListMutBackwardsIterator(CxList *list); |
|
66 |
|
67 size_t cxListFind(const CxList *list, const void *elem); |
|
68 |
|
69 bool cxListIndexValid(const CxList *list, size_t index); |
|
70 |
|
71 size_t cxListFindRemove(CxList *list, const void *elem); |
|
72 |
|
73 void cxListSort(CxList *list); |
|
74 |
|
75 void cxListReverse(CxList *list); |
|
76 |
|
77 int cxListCompare(const CxList *list, const CxList *other); |
|
78 |
|
79 void cxListFree(CxList *list); |
|
80 |
|
81 extern CxList *const cxEmptyList; |
|
82 ``` |
|
83 |
|
84 |
|
85 ## Implementing own List Structures |
30 |
86 |
31 <seealso> |
87 <seealso> |
32 <category ref="apidoc"> |
88 <category ref="apidoc"> |
33 <a href="https://ucx.sourceforge.io/api/list_8h.html">list.h</a> |
89 <a href="https://ucx.sourceforge.io/api/list_8h.html">list.h</a> |
34 </category> |
90 </category> |