src/cx/iterator.h

changeset 1180
4c3a69b9723a
parent 1115
6db21dee4929
equal deleted inserted replaced
1179:ca4c6f590a08 1180:4c3a69b9723a
47 */ 47 */
48 struct cx_iterator_base_s { 48 struct cx_iterator_base_s {
49 /** 49 /**
50 * True iff the iterator points to valid data. 50 * True iff the iterator points to valid data.
51 */ 51 */
52 cx_attr_nonnull
53 bool (*valid)(const void *); 52 bool (*valid)(const void *);
54 53
55 /** 54 /**
56 * Returns a pointer to the current element. 55 * Returns a pointer to the current element.
57 * 56 *
58 * When valid returns false, the behavior of this function is undefined. 57 * When valid returns false, the behavior of this function is undefined.
59 */ 58 */
60 cx_attr_nonnull
61 cx_attr_nodiscard
62 void *(*current)(const void *); 59 void *(*current)(const void *);
63 60
64 /** 61 /**
65 * Original implementation in case the function needs to be wrapped. 62 * Original implementation in case the function needs to be wrapped.
66 */ 63 */
67 cx_attr_nonnull
68 cx_attr_nodiscard
69 void *(*current_impl)(const void *); 64 void *(*current_impl)(const void *);
70 65
71 /** 66 /**
72 * Advances the iterator. 67 * Advances the iterator.
73 * 68 *
74 * When valid returns false, the behavior of this function is undefined. 69 * When valid returns false, the behavior of this function is undefined.
75 */ 70 */
76 cx_attr_nonnull
77 void (*next)(void *); 71 void (*next)(void *);
78 /** 72 /**
79 * Indicates whether this iterator may remove elements. 73 * Indicates whether this iterator may remove elements.
80 */ 74 */
81 bool mutating; 75 bool mutating;
225 * @param elem_count the number of elements in the array 219 * @param elem_count the number of elements in the array
226 * @return an iterator for the specified array 220 * @return an iterator for the specified array
227 * @see cxIteratorPtr() 221 * @see cxIteratorPtr()
228 */ 222 */
229 cx_attr_nodiscard 223 cx_attr_nodiscard
224 cx_attr_export
230 CxIterator cxIterator( 225 CxIterator cxIterator(
231 const void *array, 226 const void *array,
232 size_t elem_size, 227 size_t elem_size,
233 size_t elem_count 228 size_t elem_count
234 ); 229 );
255 * @param remove_keeps_order @c true if the order of elements must be preserved 250 * @param remove_keeps_order @c true if the order of elements must be preserved
256 * when removing an element 251 * when removing an element
257 * @return an iterator for the specified array 252 * @return an iterator for the specified array
258 */ 253 */
259 cx_attr_nodiscard 254 cx_attr_nodiscard
255 cx_attr_export
260 CxIterator cxMutIterator( 256 CxIterator cxMutIterator(
261 void *array, 257 void *array,
262 size_t elem_size, 258 size_t elem_size,
263 size_t elem_count, 259 size_t elem_count,
264 bool remove_keeps_order 260 bool remove_keeps_order
276 * @param elem_count the number of elements in the array 272 * @param elem_count the number of elements in the array
277 * @return an iterator for the specified array 273 * @return an iterator for the specified array
278 * @see cxIterator() 274 * @see cxIterator()
279 */ 275 */
280 cx_attr_nodiscard 276 cx_attr_nodiscard
277 cx_attr_export
281 CxIterator cxIteratorPtr( 278 CxIterator cxIteratorPtr(
282 const void *array, 279 const void *array,
283 size_t elem_count 280 size_t elem_count
284 ); 281 );
285 282
296 * @return an iterator for the specified array 293 * @return an iterator for the specified array
297 * @see cxMutIterator() 294 * @see cxMutIterator()
298 * @see cxIteratorPtr() 295 * @see cxIteratorPtr()
299 */ 296 */
300 cx_attr_nodiscard 297 cx_attr_nodiscard
298 cx_attr_export
301 CxIterator cxMutIteratorPtr( 299 CxIterator cxMutIteratorPtr(
302 void *array, 300 void *array,
303 size_t elem_count, 301 size_t elem_count,
304 bool remove_keeps_order 302 bool remove_keeps_order
305 ); 303 );

mercurial