add documentation for collection.h

Sat, 01 Jul 2023 14:29:16 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 01 Jul 2023 14:29:16 +0200
changeset 730
9fecb2769d32
parent 729
600d72644919
child 731
9c097dabba2c

add documentation for collection.h

docs/src/features.md file | annotate | diff | comparison | revisions
--- a/docs/src/features.md	Sat Jul 01 14:05:52 2023 +0200
+++ b/docs/src/features.md	Sat Jul 01 14:29:16 2023 +0200
@@ -186,6 +186,25 @@
 
 *Header file:* [collection.h](api/collection_8h.html)
 
+Collections in UCX 3 have several common features.
+If you want to implement an own collection data type that uses the same features, you can use the
+`CX_COLLECTION_MEMBERS` macro at the beginning of your struct to roll out all members a usual UCX collection has.
+```c
+struct my_fancy_collection_s {
+    CX_COLLECTION_MEMBERS
+    struct my_collection_data_s *data;
+};
+```
+Based on this structure, this header provides some convenience macros for invoking the destructor functions
+that are part of the basic collection members.
+The idea of having destructor functions within a collection is that you can destroy the collection _and_ the
+contents with one single function call.
+When you are implementing a collection, you are responsible for invoking the destructors at the right places, e.g.
+when removing (and deleting) elements in the collection, clearing the collection, or - the most prominent case -
+destroying the collection.
+
+You can always look at the UCX list and map implementations if you need some inspiration.
+
 ## List
 
 *Header file:* [list.h](api/list_8h.html)

mercurial