docs/Writerside/topics/map.h.md

changeset 1444
dd9dcbb39c2f
parent 1440
0d1430668271
child 1445
e8089a590b71
equal deleted inserted replaced
1443:6986e9ed70f3 1444:dd9dcbb39c2f
289 const CxAllocator *allocator, 289 const CxAllocator *allocator,
290 void *data); 290 void *data);
291 291
292 #include <cx/map.h> 292 #include <cx/map.h>
293 293
294 size_t cxMapClone(CxMap *dst, const CxMap *src, 294 int cxMapClone(CxMap *dst, const CxMap *src,
295 cx_clone_func clone_func, 295 cx_clone_func clone_func,
296 const CxAllocator *clone_allocator, 296 const CxAllocator *clone_allocator,
297 void *data); 297 void *data);
298 ``` 298 ```
299 299
302 But when a key already exists in the destination map, the value is overwritten with the clone from the source map. 302 But when a key already exists in the destination map, the value is overwritten with the clone from the source map.
303 If the destination map has destructors defined, they are called for the replaced element. 303 If the destination map has destructors defined, they are called for the replaced element.
304 304
305 Refer to the documentation of the [clone-function callback](allocator.h.md#clone-function) to learn how to implement it. 305 Refer to the documentation of the [clone-function callback](allocator.h.md#clone-function) to learn how to implement it.
306 306
307 The function returns the number of elements successfully cloned. 307 The function returns zero if and only if all clone operations were successful.
308 If an allocation error occurs, this might be smaller than the size of the source map.
309 308
310 > It is perfectly possible to clone items into a map of a different type. 309 > It is perfectly possible to clone items into a map of a different type.
311 > For example, you can clone entries from a map that is just storing pointers (`CX_STORE_POINTERS`) to a map that 310 > For example, you can clone entries from a map that is just storing pointers (`CX_STORE_POINTERS`) to a map that
312 > allocates the memory for the objects (and vice versa). 311 > allocates the memory for the objects (and vice versa).
313 312

mercurial