| 367 int cxListClone(CxList *dst, const CxList *src, |
367 int cxListClone(CxList *dst, const CxList *src, |
| 368 cx_clone_func clone_func, |
368 cx_clone_func clone_func, |
| 369 const CxAllocator *clone_allocator, |
369 const CxAllocator *clone_allocator, |
| 370 void *data); |
370 void *data); |
| 371 |
371 |
| |
372 int cxListCloneSimple(CxList *dst, const CxList *src); |
| |
373 |
| 372 int cxListDifference(CxList *dst, |
374 int cxListDifference(CxList *dst, |
| 373 const CxList *minuend, const CxList *subtrahend, |
375 const CxList *minuend, const CxList *subtrahend, |
| 374 cx_clone_func clone_func, |
376 cx_clone_func clone_func, |
| 375 const CxAllocator *clone_allocator, |
377 const CxAllocator *clone_allocator, |
| 376 void *data); |
378 void *data); |
| 377 |
379 |
| |
380 int cxListDifferenceSimple(CxList *dst, |
| |
381 const CxList *minuend, const CxList *subtrahend); |
| |
382 |
| 378 int cxListIntersection(CxList *dst, |
383 int cxListIntersection(CxList *dst, |
| 379 const CxList *src, const CxList *other, |
384 const CxList *src, const CxList *other, |
| 380 cx_clone_func clone_func, |
385 cx_clone_func clone_func, |
| 381 const CxAllocator *clone_allocator, |
386 const CxAllocator *clone_allocator, |
| 382 void *data); |
387 void *data); |
| 383 |
388 |
| |
389 int cxListIntersectionSimple(CxList *dst, |
| |
390 const CxList *src, const CxList *other); |
| |
391 |
| 384 int cxListUnion(CxList *dst, |
392 int cxListUnion(CxList *dst, |
| 385 const CxList *src, const CxList *other, |
393 const CxList *src, const CxList *other, |
| 386 cx_clone_func clone_func, |
394 cx_clone_func clone_func, |
| 387 const CxAllocator *clone_allocator, |
395 const CxAllocator *clone_allocator, |
| 388 void *data); |
396 void *data); |
| |
397 |
| |
398 int cxListUnionSimple(CxList *dst, |
| |
399 const CxList *src, const CxList *other); |
| 389 ``` |
400 ``` |
| 390 |
401 |
| 391 With `cxListClone()` you can create deep copies of the elements in a list and insert them into another list. |
402 With `cxListClone()` you can create deep copies of the elements in a list and insert them into another list. |
| 392 The destination list does not need to be empty, in which case the elements will be appended. |
403 The destination list does not need to be empty, in which case the elements will be appended. |
| 393 Depending on the concrete list implementation, `cxListClone()` tries to allocate enough memory up-front, before trying |
404 Depending on the concrete list implementation, `cxListClone()` tries to allocate enough memory up-front, before trying |
| 404 |
415 |
| 405 However, when the `dst` list already contains elements, all functions will only append the result of the operation to that list. |
416 However, when the `dst` list already contains elements, all functions will only append the result of the operation to that list. |
| 406 That means, the `dst` list is only guaranteed to be sorted, when it was empty and the input lists are all sorted. |
417 That means, the `dst` list is only guaranteed to be sorted, when it was empty and the input lists are all sorted. |
| 407 |
418 |
| 408 Refer to the documentation of the [clone-function callback](allocator.h.md#clone-function) to learn how to implement it. |
419 Refer to the documentation of the [clone-function callback](allocator.h.md#clone-function) to learn how to implement it. |
| |
420 |
| |
421 The _simple_ versions of the above functions use an internal shallow clone function |
| |
422 which uses `memcpy()` to copy the elements. |
| |
423 If the destination map is storing pointers, this internal clone function uses the current default allocator to allocate the memory. |
| 409 |
424 |
| 410 The functions return zero if and only if all clone operations were successful. |
425 The functions return zero if and only if all clone operations were successful. |
| 411 |
426 |
| 412 > It is perfectly possible to clone items into a list of a different type. |
427 > It is perfectly possible to clone items into a list of a different type. |
| 413 > For example, you can clone elements from a list that is just storing pointers (`CX_STORE_POINTERS`) to a list that |
428 > For example, you can clone elements from a list that is just storing pointers (`CX_STORE_POINTERS`) to a list that |