| 179 * |
175 * |
| 180 * @param iter the iterator |
176 * @param iter the iterator |
| 181 * @return @c true if removal is allowed, @c false otherwise |
177 * @return @c true if removal is allowed, @c false otherwise |
| 182 */ |
178 */ |
| 183 #define cxIteratorFlagRemoval(iter) ((iter).base.remove = (iter).base.allow_remove) |
179 #define cxIteratorFlagRemoval(iter) ((iter).base.remove = (iter).base.allow_remove) |
| 184 |
|
| 185 /** |
|
| 186 * Obtains a reference to an arbitrary iterator. |
|
| 187 * |
|
| 188 * This is useful for APIs that expect some iterator as an argument. |
|
| 189 * |
|
| 190 * @param iter the iterator |
|
| 191 * @return (@c struct @c cx_iterator_base_s*) a pointer to the iterator |
|
| 192 */ |
|
| 193 #define cxIteratorRef(iter) &((iter).base) |
|
| 194 |
180 |
| 195 /** |
181 /** |
| 196 * Loops over an iterator. |
182 * Loops over an iterator. |
| 197 * |
183 * |
| 198 * @param type the type of the elements |
184 * @param type the type of the elements |
| 218 * @param elem_size the size of one array element |
204 * @param elem_size the size of one array element |
| 219 * @param elem_count the number of elements in the array |
205 * @param elem_count the number of elements in the array |
| 220 * @return an iterator for the specified array |
206 * @return an iterator for the specified array |
| 221 * @see cxIteratorPtr() |
207 * @see cxIteratorPtr() |
| 222 */ |
208 */ |
| 223 cx_attr_nodiscard |
209 CX_EXTERN CX_NODISCARD |
| 224 CX_EXPORT CxIterator cxIterator(const void *array, |
210 CxIterator cxIterator(const void *array, |
| 225 size_t elem_size, size_t elem_count); |
211 size_t elem_size, size_t elem_count); |
| 226 |
212 |
| 227 /** |
213 /** |
| 228 * Creates an iterator for the specified plain pointer array. |
214 * Creates an iterator for the specified plain pointer array. |
| 229 * |
215 * |
| 235 * @param array a pointer to the array (can be @c NULL) |
221 * @param array a pointer to the array (can be @c NULL) |
| 236 * @param elem_count the number of elements in the array |
222 * @param elem_count the number of elements in the array |
| 237 * @return an iterator for the specified array |
223 * @return an iterator for the specified array |
| 238 * @see cxIterator() |
224 * @see cxIterator() |
| 239 */ |
225 */ |
| 240 cx_attr_nodiscard |
226 CX_EXTERN CX_NODISCARD |
| 241 CX_EXPORT CxIterator cxIteratorPtr(const void *array, size_t elem_count); |
227 CxIterator cxIteratorPtr(const void *array, size_t elem_count); |
| 242 |
|
| 243 #ifdef __cplusplus |
|
| 244 } // extern "C" |
|
| 245 #endif |
|
| 246 |
228 |
| 247 #endif // UCX_ITERATOR_H |
229 #endif // UCX_ITERATOR_H |