Sat, 25 Jan 2025 13:44:24 +0100
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:
1141
diff
changeset
|
1 | # Collections |
1141 | 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 | 7 | Collections in UCX 3 have several common features. |
8 | If you want to implement an own collection data type that uses the same features, you can use the | |
9 | `CX_COLLECTION_BASE` macro at the beginning of your struct to roll out all members a usual UCX collection has. | |
10 | ```c | |
11 | struct my_fancy_collection_s { | |
12 | CX_COLLECTION_BASE; | |
13 | struct my_collection_data_s *data; | |
14 | }; | |
15 | ``` | |
16 | Based on this structure, this header provides some convenience macros for invoking the destructor functions | |
17 | that are part of the basic collection members. | |
18 | The idea of having destructor functions within a collection is that you can destroy the collection _and_ the | |
19 | contents with one single function call. | |
20 | When you are implementing a collection, you are responsible for invoking the destructors at the right places, e.g. | |
21 | when removing (and deleting) elements in the collection, clearing the collection, or - the most prominent case - | |
22 | destroying the collection. | |
23 | ||
24 | You can always look at the UCX list and map implementations if you need some inspiration. |