143 |
143 |
144 /** |
144 /** |
145 * Iterator type. |
145 * Iterator type. |
146 * |
146 * |
147 * An iterator points to a certain element in a (possibly unbounded) chain of elements. |
147 * An iterator points to a certain element in a (possibly unbounded) chain of elements. |
148 * Iterators that are based on collections (which have a defined "first" element), are supposed |
148 * Iterators that are based on collections (which have a defined "first" element) are supposed |
149 * to be "position-aware", which means that they keep track of the current index within the collection. |
149 * to be "position-aware", which means that they keep track of the current index within the collection. |
150 * |
150 * |
151 * @note Objects that are pointed to by an iterator are always mutable through that iterator. However, |
151 * @note Objects that are pointed to by an iterator are always mutable through that iterator. However, |
152 * any concurrent mutation of the collection other than by this iterator makes this iterator invalid, |
152 * any concurrent mutation of the collection other than by this iterator makes this iterator invalid, |
153 * and it must not be used anymore. |
153 * and it must not be used anymore. |
180 * @param iter the iterator |
180 * @param iter the iterator |
181 */ |
181 */ |
182 #define cxIteratorNext(iter) (iter).base.next(&iter) |
182 #define cxIteratorNext(iter) (iter).base.next(&iter) |
183 |
183 |
184 /** |
184 /** |
185 * Flags the current element for removal, if this iterator is mutating. |
185 * Flags the current element for removal if this iterator is mutating. |
186 * |
186 * |
187 * Does nothing for non-mutating iterators. |
187 * Does nothing for non-mutating iterators. |
188 * |
188 * |
189 * @param iter the iterator |
189 * @param iter the iterator |
190 */ |
190 */ |
212 |
212 |
213 |
213 |
214 /** |
214 /** |
215 * Creates an iterator for the specified plain array. |
215 * Creates an iterator for the specified plain array. |
216 * |
216 * |
217 * The @p array can be @c NULL in which case the iterator will be immediately |
217 * The @p array can be @c NULL, in which case the iterator will be immediately |
218 * initialized such that #cxIteratorValid() returns @c false. |
218 * initialized such that #cxIteratorValid() returns @c false. |
219 * |
219 * |
220 * This iterator yields the addresses of the array elements. |
220 * This iterator yields the addresses of the array elements. |
221 * If you want to iterator over an array of pointers, you can |
221 * If you want to iterator over an array of pointers, you can |
222 * use cxIteratorPtr() to create an iterator which directly |
222 * use cxIteratorPtr() to create an iterator which directly |
246 * When @p remove_keeps_order is set to @c false, removing an element will only |
246 * 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 |
247 * 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 |
248 * moving all subsequent elements by one. Usually, when the order of elements is |
249 * not important, this parameter should be set to @c false. |
249 * not important, this parameter should be set to @c false. |
250 * |
250 * |
251 * The @p array can be @c NULL in which case the iterator will be immediately |
251 * The @p array can be @c NULL, in which case the iterator will be immediately |
252 * initialized such that #cxIteratorValid() returns @c false. |
252 * initialized such that #cxIteratorValid() returns @c false. |
253 * |
253 * |
254 * |
254 * |
255 * @param array a pointer to the array (can be @c NULL) |
255 * @param array a pointer to the array (can be @c NULL) |
256 * @param elem_size the size of one array element |
256 * @param elem_size the size of one array element |
270 |
270 |
271 /** |
271 /** |
272 * Creates an iterator for the specified plain pointer array. |
272 * Creates an iterator for the specified plain pointer array. |
273 * |
273 * |
274 * This iterator assumes that every element in the array is a pointer |
274 * This iterator assumes that every element in the array is a pointer |
275 * and yields exactly those pointers during iteration (while in contrast |
275 * and yields exactly those pointers during iteration (on the other |
276 * an iterator created with cxIterator() would return the addresses |
276 * hand, an iterator created with cxIterator() would return the |
277 * of those pointers within the array). |
277 * addresses of those pointers within the array). |
278 * |
278 * |
279 * @param array a pointer to the array (can be @c NULL) |
279 * @param array a pointer to the array (can be @c NULL) |
280 * @param elem_count the number of elements in the array |
280 * @param elem_count the number of elements in the array |
281 * @return an iterator for the specified array |
281 * @return an iterator for the specified array |
282 * @see cxIterator() |
282 * @see cxIterator() |