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