diff -r 946895d19dde -r 185dc2a4b45c docs/Writerside/topics/map.h.md --- a/docs/Writerside/topics/map.h.md Tue Nov 11 18:43:08 2025 +0100 +++ b/docs/Writerside/topics/map.h.md Tue Nov 11 18:47:48 2025 +0100 @@ -197,7 +197,7 @@ void *cxMapEmplace(CxMap *map, KeyType key); ``` -The function `cxMapPut()` stores the specified `key` / `value` pair, +The function `cxMapPut()` stores the specified `key` / `value` pair and returns zero if the element was successfully put into the map and non-zero otherwise. The key is always copied. @@ -250,8 +250,8 @@ The function `cxMapRemove()` retrieves and removes a value stored under the specified `key`. If [destructor functions](collection.h.md#destructor-functions) are registered, they are called before removal. -On the other hand, `cxMapRemoveAndGet()` does not invoke the destructor functions, -and instead copies the value into the `targetbuf` which must be sufficiently large to hold the value. +On the other hand, `cxMapRemoveAndGet()` does not invoke the destructor functions +and instead copies the value into the `targetbuf`, which must be large enough to hold the value. In either case, the functions return zero when an element was found under the specified key, and non-zero otherwise. @@ -272,13 +272,13 @@ The above functions create iterators over the pairs, keys, or values of the specified `map`, respectively. -Iterators over pairs yield elements of type `CxMapEntry*` which is a struct containing a pointer to the `key` and the value, respectively. +Iterators over pairs yield elements of the type `CxMapEntry*` which is a struct containing a pointer to the `key` and the value, respectively. -Iterators over keys yield elements of type `const CxHashKey*` (cf. [CxHashKey documentation](hash_key.h.md)). +Iterators over keys yield elements of the type `const CxHashKey*` (cf. [CxHashKey documentation](hash_key.h.md)). The behavior of iterators over values depends on the concrete implementation. Implementations are encouraged to support `CX_STORE_POINTERS`. -If used, the `void*` elements the iterator yields, shall be directly the stored pointers. +If used, the `void*` elements the iterator yields shall be directly the stored pointers. Otherwise, the iterator shall yield pointers to the map's memory where the value is stored. It is always safe to call the above functions on a `NULL`-pointer. @@ -356,7 +356,7 @@ 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. -Likewise, `cxMapIntersection()` and `cxMapListIntersection()` only clone an element from the source map, +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`. @@ -388,7 +388,7 @@ void cxMapFree(CxMap *map); ``` -The function `cxMapFree()` invokes the [destructor functions](collection.h.md#destructor-functions) for all elements, +The function `cxMapFree()` invokes the [destructor functions](collection.h.md#destructor-functions) for all elements and then deallocates the entire memory for the map. ## Implement own Map Structures @@ -404,7 +404,7 @@ } CxMapEntry; ``` -When you are declaring your map structure, a `CxMap` member must be embedded as first member of this structure. +When you are declaring your map structure, a `CxMap` member must be embedded as the first member of this structure. Secondly, you need to implement the `cx_map_class` and assign it when allocating your map. ```C