--- a/docs/Writerside/topics/map.h.md Wed Nov 05 22:39:39 2025 +0100 +++ b/docs/Writerside/topics/map.h.md Wed Nov 05 23:04:46 2025 +0100 @@ -324,6 +324,11 @@ cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data); + +int cxMapUnion(CxMap *dst, const CxMap *src, + 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. @@ -337,6 +342,11 @@ This is equivalent to computing the set difference for the set of keys. Likewise, `cxMapIntersection()` and `cxMapListIntersection()` only clone an element from the source map, when the key is contained in _both_ collections. +The function `cxMapUnion()` only clones elements from `src` to `dst` when their key is not present in `dst`. + +> The function `cxMapUnion()` does not operate on three maps for the sake of simplicity. +> If you want to combine two maps without modifying either of them, you can first use `cxMapClone()` +> to clone the first map into a new, empty, map, and then use `cxMapUnion()`. Refer to the documentation of the [clone-function callback](allocator.h.md#clone-function) to learn how to implement it.