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