src/cx/iterator.h

changeset 1070
0a5a356a4486
parent 1035
9b6ded88d7a0
child 1096
2cb1ed4da55d
equal deleted inserted replaced
1069:6565e7ef5ee3 1070:0a5a356a4486
228 * Creates an iterator for the specified plain array. 228 * Creates an iterator for the specified plain array.
229 * 229 *
230 * The \p array can be \c NULL in which case the iterator will be immediately 230 * The \p array can be \c NULL in which case the iterator will be immediately
231 * initialized such that #cxIteratorValid() returns \c false. 231 * initialized such that #cxIteratorValid() returns \c false.
232 * 232 *
233 * This iterator yields the addresses of the array elements.
234 * If you want to iterator over an array of pointers, you can
235 * use cxIteratorPtr() to create an iterator which directly
236 * yields the stored pointers.
233 * 237 *
234 * @param array a pointer to the array (can be \c NULL) 238 * @param array a pointer to the array (can be \c NULL)
235 * @param elem_size the size of one array element 239 * @param elem_size the size of one array element
236 * @param elem_count the number of elements in the array 240 * @param elem_count the number of elements in the array
237 * @return an iterator for the specified array 241 * @return an iterator for the specified array
242 * @see cxIteratorPtr()
238 */ 243 */
239 cx_attr_nodiscard 244 cx_attr_nodiscard
240 CxIterator cxIterator( 245 CxIterator cxIterator(
241 const void *array, 246 const void *array,
242 size_t elem_size, 247 size_t elem_size,
272 size_t elem_size, 277 size_t elem_size,
273 size_t elem_count, 278 size_t elem_count,
274 bool remove_keeps_order 279 bool remove_keeps_order
275 ); 280 );
276 281
282 /**
283 * Creates an iterator for the specified plain pointer array.
284 *
285 * This iterator assumes that every element in the array is a pointer
286 * and yields exactly those pointers during iteration (while in contrast
287 * an iterator created with cxIterator() would return the addresses
288 * of those pointers within the array).
289 *
290 * @param array a pointer to the array (can be \c NULL)
291 * @param elem_count the number of elements in the array
292 * @return an iterator for the specified array
293 * @see cxIterator()
294 */
295 cx_attr_nodiscard
296 CxIterator cxIteratorPtr(
297 const void *array,
298 size_t elem_count
299 );
300
301 /**
302 * Creates a mutating iterator for the specified plain pointer array.
303 *
304 * This is the mutating variant of cxIteratorPtr(). See also
305 * cxMutIterator().
306 *
307 * @param array a pointer to the array (can be \c NULL)
308 * @param elem_count the number of elements in the array
309 * @param remove_keeps_order \c true if the order of elements must be preserved
310 * when removing an element
311 * @return an iterator for the specified array
312 * @see cxMutIterator()
313 * @see cxIteratorPtr()
314 */
315 cx_attr_nodiscard
316 CxIterator cxMutIteratorPtr(
317 void *array,
318 size_t elem_count,
319 bool remove_keeps_order
320 );
321
277 #ifdef __cplusplus 322 #ifdef __cplusplus
278 } // extern "C" 323 } // extern "C"
279 #endif 324 #endif
280 325
281 #endif // UCX_ITERATOR_H 326 #endif // UCX_ITERATOR_H

mercurial