| 212 * This iterator yields the addresses of the array elements. |
212 * This iterator yields the addresses of the array elements. |
| 213 * If you want to iterator over an array of pointers, you can |
213 * If you want to iterator over an array of pointers, you can |
| 214 * use cxIteratorPtr() to create an iterator which directly |
214 * use cxIteratorPtr() to create an iterator which directly |
| 215 * yields the stored pointers. |
215 * yields the stored pointers. |
| 216 * |
216 * |
| 217 * While the iterator is in use, the array may only be altered by removing |
|
| 218 * elements through #cxIteratorFlagRemoval(). Every other change to the array |
|
| 219 * will bring this iterator to an undefined state. |
|
| 220 * |
|
| 221 * When @p remove_keeps_order is set to @c false, removing an element will only |
|
| 222 * move the last element to the position of the removed element, instead of |
|
| 223 * moving all subsequent elements by one. Usually, when the order of elements is |
|
| 224 * not important, this parameter should be set to @c false. |
|
| 225 * |
|
| 226 * @param array a pointer to the array (can be @c NULL) |
217 * @param array a pointer to the array (can be @c NULL) |
| 227 * @param elem_size the size of one array element |
218 * @param elem_size the size of one array element |
| 228 * @param elem_count the number of elements in the array |
219 * @param elem_count the number of elements in the array |
| 229 * @param remove_keeps_order @c true if the order of elements must be preserved |
|
| 230 * when removing an element |
|
| 231 * @return an iterator for the specified array |
220 * @return an iterator for the specified array |
| 232 * @see cxIteratorPtr() |
221 * @see cxIteratorPtr() |
| 233 */ |
222 */ |
| 234 cx_attr_nodiscard |
223 cx_attr_nodiscard |
| 235 CX_EXPORT CxIterator cxIterator(const void *array, |
224 CX_EXPORT CxIterator cxIterator(const void *array, |
| 236 size_t elem_size, size_t elem_count, bool remove_keeps_order); |
225 size_t elem_size, size_t elem_count); |
| 237 |
226 |
| 238 /** |
227 /** |
| 239 * Creates an iterator for the specified plain pointer array. |
228 * Creates an iterator for the specified plain pointer array. |
| 240 * |
229 * |
| 241 * This iterator assumes that every element in the array is a pointer |
230 * This iterator assumes that every element in the array is a pointer |
| 242 * and yields exactly those pointers during iteration (on the other |
231 * and yields exactly those pointers during iteration (on the other |
| 243 * hand, an iterator created with cxIterator() would return the |
232 * hand, an iterator created with cxIterator() would return the |
| 244 * addresses of those pointers within the array). |
233 * addresses of those pointers within the array). |
| 245 * |
234 * |
| 246 * While the iterator is in use, the array may only be altered by removing |
|
| 247 * elements through #cxIteratorFlagRemoval(). Every other change to the array |
|
| 248 * will bring this iterator to an undefined state. |
|
| 249 * |
|
| 250 * When @p remove_keeps_order is set to @c false, removing an element will only |
|
| 251 * move the last element to the position of the removed element, instead of |
|
| 252 * moving all subsequent elements by one. Usually, when the order of elements is |
|
| 253 * not important, this parameter should be set to @c false. |
|
| 254 * |
|
| 255 * @param array a pointer to the array (can be @c NULL) |
235 * @param array a pointer to the array (can be @c NULL) |
| 256 * @param elem_count the number of elements in the array |
236 * @param elem_count the number of elements in the array |
| 257 * @param remove_keeps_order @c true if the order of elements must be preserved |
|
| 258 * when removing an element |
|
| 259 * @return an iterator for the specified array |
237 * @return an iterator for the specified array |
| 260 * @see cxIterator() |
238 * @see cxIterator() |
| 261 */ |
239 */ |
| 262 cx_attr_nodiscard |
240 cx_attr_nodiscard |
| 263 CX_EXPORT CxIterator cxIteratorPtr(const void *array, size_t elem_count, |
241 CX_EXPORT CxIterator cxIteratorPtr(const void *array, size_t elem_count); |
| 264 bool remove_keeps_order); |
|
| 265 |
242 |
| 266 #ifdef __cplusplus |
243 #ifdef __cplusplus |
| 267 } // extern "C" |
244 } // extern "C" |
| 268 #endif |
245 #endif |
| 269 |
246 |