docs/Writerside/topics/list.h.md

changeset 1428
0ac4aa1737fd
parent 1421
809eb30cd621
child 1429
6e0c3a8a914a
--- a/docs/Writerside/topics/list.h.md	Fri Oct 17 14:14:21 2025 +0200
+++ b/docs/Writerside/topics/list.h.md	Fri Oct 17 15:04:56 2025 +0200
@@ -148,7 +148,9 @@
 Be aware that when the list is storing pointers, the allocated memory will be for the pointer, not the actual element's data.
 
 The function `cxListInsertSorted()` inserts the element at the correct position so that the list remains sorted according to the list's compare function.
-On top of that, `cxListInsertUnique()` inserts the element only if it is not already in the list. 
+It is important that the list is already sorted before calling this function.
+On the other hand, `cxListInsertUnique()` inserts the element only if it is not already in the list.
+In this case it is strongly recommended that the list is already sorted but not required; the function will fall back to an inefficient algorithm when the list is not sorted.
 
 When you are currently iterating through a list, you can insert elements before or after the current position of the iterator
 with `cxListInsertBefore()` or `cxListInsertAfter()`, respectively.
@@ -160,17 +162,17 @@
 On the other hand, the `array` argument for `cxListAddArray()`, `cxListInsertArray()`, `cxListInsertSortedArray()`, and `cxListInsertUniqueArray()`
 must always point to an array of elements to be added (i.e., either an array of pointers or an array of actual elements).
 
-When calling `cxListInsertSortedArray()` or `cxListInsertUniqueArray()`, the `array` must already be sorted.
-
 The return values of the array-inserting functions are the number of elements that have been successfully _processed_.
 Usually this is equivalent to the number of inserted elements, except for `cxListInsertUniqueArray()`,
 where the actual number of inserted elements may be lower than the number of successfully processed elements.
 
 > Implementations are required to optimize the insertion of a sorted array into a sorted list in linear time,
 > while inserting each element separately via `cxListInsertSorted()` may take quadratic time.
-
-> The functions do not check if the list is already sorted, nor do they actively sort the list.
-> In debug builds, invoking the functions on unsorted lists may trigger an assertion.
+> 
+> When used with sorted lists, the arrays passed to the functions must also be sorted according to the list's compare function.
+> Only when `cxListInsertUniqueArray()` is used with a list that is not sorted, the array does not need to be sorted.
+> 
+> The functions do not check if the passed arrays are sorted.
 > {style="note"}
 
 ## Access and Find

mercurial