--- a/docs/Writerside/topics/map.h.md Sun Oct 26 11:50:33 2025 +0100 +++ b/docs/Writerside/topics/map.h.md Sun Oct 26 12:01:28 2025 +0100 @@ -300,6 +300,18 @@ cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); + +int cxMapDifference(CxMap *dst, + const CxMap *minuend, const CxMap *subtrahend, + cx_clone_func clone_func, + const CxAllocator *clone_allocator, + void *data); + +int cxMapListDifference(CxMap *dst, + const CxMap *src, const CxList *keys, + cx_clone_func clone_func, + const CxAllocator *clone_allocator, + void *data); ``` With `cxMapClone()` you can create deep copies of the values in one map and insert them into another map. @@ -307,9 +319,14 @@ But when a key already exists in the destination map, the value is overwritten with the clone from the source map. If the destination map has destructors defined, they are called for the replaced element. +The functions `cxMapDifference()` and `cxMapListDifference()` are similar to `cxMapClone()` +except that they only clone an element from the source map, when the key is _not_ contained in the +other map (or list, respectively). +This is equivalent to computing the set difference for the set of keys. + Refer to the documentation of the [clone-function callback](allocator.h.md#clone-function) to learn how to implement it. -The function returns zero if and only if all clone operations were successful. +The functions return zero if and only if all clone operations were successful. > It is perfectly possible to clone items into a map of a different type. > For example, you can clone entries from a map that is just storing pointers (`CX_STORE_POINTERS`) to a map that