| 131 |
131 |
| 132 void cx_array_remove_array_fast(CxArray array, size_t index, size_t n); |
132 void cx_array_remove_array_fast(CxArray array, size_t index, size_t n); |
| 133 ``` |
133 ``` |
| 134 |
134 |
| 135 The functions `cx_array_remove()` and `cx_array_remove_array()` remove one or more elements from the array by shifting the remaining elements by the number of removed elements. |
135 The functions `cx_array_remove()` and `cx_array_remove_array()` remove one or more elements from the array by shifting the remaining elements by the number of removed elements. |
| 136 The functions `cx_array_remove_fast()` and `cx_array_remove_array_fast()` on the other hand copy elements from the end of the array into the gap to fill the removed elements. |
136 The functions `cx_array_remove_fast()` and `cx_array_remove_array_fast()` on the other hand, copy elements from the end of the array into the gap to fill the removed elements. |
| 137 Therefore, if the order of the elements does not matter, you can use the fast versions of these functions for better performance. |
137 Therefore, if the order of the elements does not matter, you can use the fast versions of these functions for better performance. |
| 138 |
138 |
| 139 > When you specify an `index` that is out-of-bounds or choose a number `n` of elements that would overflow the array, |
139 > When you specify an `index` that is out-of-bounds or choose a number `n` of elements that would overflow the array, |
| 140 > the above functions only remove as many elements as possible. |
140 > the above functions only remove as many elements as possible. |
| 141 > So it's safe to use them without any bounds checking. |
141 > So it's safe to use them without any bounds checking. |
| 155 ``` |
155 ``` |
| 156 |
156 |
| 157 With simple `cx_compare_func` functions, arrays can always be sorted with standard `qsort()`. |
157 With simple `cx_compare_func` functions, arrays can always be sorted with standard `qsort()`. |
| 158 Sorting arrays with `cx_compare_func2` functions, however, need special support by either `qsort_r()` (GNU) or `qsort_s()` (ISO). |
158 Sorting arrays with `cx_compare_func2` functions, however, need special support by either `qsort_r()` (GNU) or `qsort_s()` (ISO). |
| 159 However, both functions come with their own challenges. |
159 However, both functions come with their own challenges. |
| 160 On the one hand, `qsort_r()` is not ISO standard, and on the other hand `qsort_s()` is only optional and has an incorrect parameter order in the Microsoft C library. |
160 On the one hand, `qsort_r()` is not ISO standard, and on the other hand, `qsort_s()` is only optional and has an incorrect parameter order in the Microsoft C library. |
| 161 |
161 |
| 162 To provide a platform independent solution, UCX detects if `qsort_r()` is available and implements a fallback when it is not. |
162 To provide a platform-independent solution, UCX detects if `qsort_r()` is available and implements a fallback when it is not. |
| 163 You can safely use `cx_array_qsort_c()` everywhere wehere you would use `qsort_r()`. |
163 You can safely use `cx_array_qsort_c()` everywhere wehere you would use `qsort_r()`. |
| 164 |
164 |
| 165 The functions `cx_array_sort()` and `cx_array_sort_c()` are for convenient work with arrays declared with `CX_ARRAY()`. |
165 The functions `cx_array_sort()` and `cx_array_sort_c()` are for convenient work with arrays declared with `CX_ARRAY()`. |
| 166 |
166 |
| 167 ## Insertion Sort |
167 ## Insertion Sort |