| 220 * This iterator yields the addresses of the array elements. |
212 * This iterator yields the addresses of the array elements. |
| 221 * 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 |
| 222 * use cxIteratorPtr() to create an iterator which directly |
214 * use cxIteratorPtr() to create an iterator which directly |
| 223 * yields the stored pointers. |
215 * yields the stored pointers. |
| 224 * |
216 * |
| 225 * @param array a pointer to the array (can be @c NULL) |
|
| 226 * @param elem_size the size of one array element |
|
| 227 * @param elem_count the number of elements in the array |
|
| 228 * @return an iterator for the specified array |
|
| 229 * @see cxIteratorPtr() |
|
| 230 */ |
|
| 231 cx_attr_nodiscard |
|
| 232 cx_attr_export |
|
| 233 CxIterator cxIterator( |
|
| 234 const void *array, |
|
| 235 size_t elem_size, |
|
| 236 size_t elem_count |
|
| 237 ); |
|
| 238 |
|
| 239 /** |
|
| 240 * Creates a mutating iterator for the specified plain array. |
|
| 241 * |
|
| 242 * While the iterator is in use, the array may only be altered by removing |
217 * While the iterator is in use, the array may only be altered by removing |
| 243 * elements through #cxIteratorFlagRemoval(). Every other change to the array |
218 * elements through #cxIteratorFlagRemoval(). Every other change to the array |
| 244 * will bring this iterator to an undefined state. |
219 * will bring this iterator to an undefined state. |
| 245 * |
220 * |
| 246 * When @p remove_keeps_order is set to @c false, removing an element will only |
221 * When @p remove_keeps_order is set to @c false, removing an element will only |
| 247 * move the last element to the position of the removed element, instead of |
222 * move the last element to the position of the removed element, instead of |
| 248 * moving all subsequent elements by one. Usually, when the order of elements is |
223 * moving all subsequent elements by one. Usually, when the order of elements is |
| 249 * not important, this parameter should be set to @c false. |
224 * not important, this parameter should be set to @c false. |
| 250 * |
|
| 251 * The @p array can be @c NULL, in which case the iterator will be immediately |
|
| 252 * initialized such that #cxIteratorValid() returns @c false. |
|
| 253 * |
|
| 254 * |
225 * |
| 255 * @param array a pointer to the array (can be @c NULL) |
226 * @param array a pointer to the array (can be @c NULL) |
| 256 * @param elem_size the size of one array element |
227 * @param elem_size the size of one array element |
| 257 * @param elem_count the number of elements in the array |
228 * @param elem_count the number of elements in the array |
| 258 * @param remove_keeps_order @c true if the order of elements must be preserved |
229 * @param remove_keeps_order @c true if the order of elements must be preserved |
| 259 * when removing an element |
230 * when removing an element |
| 260 * @return an iterator for the specified array |
231 * @return an iterator for the specified array |
| |
232 * @see cxIteratorPtr() |
| 261 */ |
233 */ |
| 262 cx_attr_nodiscard |
234 cx_attr_nodiscard |
| 263 cx_attr_export |
235 CX_EXPORT CxIterator cxIterator(const void *array, |
| 264 CxIterator cxMutIterator( |
236 size_t elem_size, size_t elem_count, bool remove_keeps_order); |
| 265 void *array, |
|
| 266 size_t elem_size, |
|
| 267 size_t elem_count, |
|
| 268 bool remove_keeps_order |
|
| 269 ); |
|
| 270 |
237 |
| 271 /** |
238 /** |
| 272 * Creates an iterator for the specified plain pointer array. |
239 * Creates an iterator for the specified plain pointer array. |
| 273 * |
240 * |
| 274 * This iterator assumes that every element in the array is a pointer |
241 * This iterator assumes that every element in the array is a pointer |
| 275 * and yields exactly those pointers during iteration (on the other |
242 * and yields exactly those pointers during iteration (on the other |
| 276 * hand, an iterator created with cxIterator() would return the |
243 * hand, an iterator created with cxIterator() would return the |
| 277 * addresses of those pointers within the array). |
244 * addresses of those pointers within the array). |
| 278 * |
245 * |
| 279 * @param array a pointer to the array (can be @c NULL) |
246 * While the iterator is in use, the array may only be altered by removing |
| 280 * @param elem_count the number of elements in the array |
247 * elements through #cxIteratorFlagRemoval(). Every other change to the array |
| 281 * @return an iterator for the specified array |
248 * will bring this iterator to an undefined state. |
| 282 * @see cxIterator() |
249 * |
| 283 */ |
250 * When @p remove_keeps_order is set to @c false, removing an element will only |
| 284 cx_attr_nodiscard |
251 * move the last element to the position of the removed element, instead of |
| 285 cx_attr_export |
252 * moving all subsequent elements by one. Usually, when the order of elements is |
| 286 CxIterator cxIteratorPtr( |
253 * not important, this parameter should be set to @c false. |
| 287 const void *array, |
|
| 288 size_t elem_count |
|
| 289 ); |
|
| 290 |
|
| 291 /** |
|
| 292 * Creates a mutating iterator for the specified plain pointer array. |
|
| 293 * |
|
| 294 * This is the mutating variant of cxIteratorPtr(). See also |
|
| 295 * cxMutIterator(). |
|
| 296 * |
254 * |
| 297 * @param array a pointer to the array (can be @c NULL) |
255 * @param array a pointer to the array (can be @c NULL) |
| 298 * @param elem_count the number of elements in the array |
256 * @param elem_count the number of elements in the array |
| 299 * @param remove_keeps_order @c true if the order of elements must be preserved |
257 * @param remove_keeps_order @c true if the order of elements must be preserved |
| 300 * when removing an element |
258 * when removing an element |
| 301 * @return an iterator for the specified array |
259 * @return an iterator for the specified array |
| 302 * @see cxMutIterator() |
260 * @see cxIterator() |
| 303 * @see cxIteratorPtr() |
|
| 304 */ |
261 */ |
| 305 cx_attr_nodiscard |
262 cx_attr_nodiscard |
| 306 cx_attr_export |
263 CX_EXPORT CxIterator cxIteratorPtr(const void *array, size_t elem_count, |
| 307 CxIterator cxMutIteratorPtr( |
264 bool remove_keeps_order); |
| 308 void *array, |
|
| 309 size_t elem_count, |
|
| 310 bool remove_keeps_order |
|
| 311 ); |
|
| 312 |
265 |
| 313 #ifdef __cplusplus |
266 #ifdef __cplusplus |
| 314 } // extern "C" |
267 } // extern "C" |
| 315 #endif |
268 #endif |
| 316 |
269 |