docs/Writerside/topics/list.h.md

changeset 1465
dc886f1a6155
parent 1453
b6fc5b1d5c5d
equal deleted inserted replaced
1464:9a10af83cfab 1465:dc886f1a6155
372 int cxListDifference(CxList *dst, 372 int cxListDifference(CxList *dst,
373 const CxList *minuend, const CxList *subtrahend, 373 const CxList *minuend, const CxList *subtrahend,
374 cx_clone_func clone_func, 374 cx_clone_func clone_func,
375 const CxAllocator *clone_allocator, 375 const CxAllocator *clone_allocator,
376 void *data); 376 void *data);
377
378 int cxListIntersection(CxList *dst,
379 const CxList *src, const CxList *other,
380 cx_clone_func clone_func,
381 const CxAllocator *clone_allocator,
382 void *data);
377 ``` 383 ```
378 384
379 With `cxListClone()` you can create deep copies of the elements in a list and insert them into another list. 385 With `cxListClone()` you can create deep copies of the elements in a list and insert them into another list.
380 The destination list does not need to be empty, in which case the elements will be appended. 386 The destination list does not need to be empty, in which case the elements will be appended.
381 Depending on the concrete list implementation, `cxListClone()` tries to allocate enough memory up-front, before trying 387 Depending on the concrete list implementation, `cxListClone()` tries to allocate enough memory up-front, before trying
382 to insert anything. 388 to insert anything.
383 389
384 The function `cxListDifference()` is similar to `cxListClone()`, 390 The function `cxListDifference()` is similar to `cxListClone()`,
385 except that it only clones elements from the minuend that are _not_ contained in the subtrahend. 391 except that it only clones elements from the minuend that are _not_ contained in the subtrahend,
386 It is optimized for sorted lists, in which case it will take linear time instead of quadratic time for the operation. 392 while `cxListIntersection()` only clones elements that _are_ contained in both lists.
393 Both functions are optimized for sorted lists, in which case they will take linear time instead of quadratic time for the operation.
387 394
388 Refer to the documentation of the [clone-function callback](allocator.h.md#clone-function) to learn how to implement it. 395 Refer to the documentation of the [clone-function callback](allocator.h.md#clone-function) to learn how to implement it.
389 396
390 The functions return zero if and only if all clone operations were successful. 397 The functions return zero if and only if all clone operations were successful.
391 398

mercurial