src/ucx/cx/iterator.h

changeset 504
c094afcdfb27
parent 490
d218607f5a7e
equal deleted inserted replaced
503:aeaf7db26fac 504:c094afcdfb27
49 __attribute__ ((__nonnull__)) 49 __attribute__ ((__nonnull__))
50 bool (*valid)(void const *); 50 bool (*valid)(void const *);
51 51
52 /** 52 /**
53 * Returns a pointer to the current element. 53 * Returns a pointer to the current element.
54 *
55 * When valid returns false, the behavior of this function is undefined.
54 */ 56 */
55 __attribute__ ((__nonnull__)) 57 __attribute__ ((__nonnull__))
56 void *(*current)(void const *); 58 void *(*current)(void const *);
57 59
58 /** 60 /**
61 __attribute__ ((__nonnull__)) 63 __attribute__ ((__nonnull__))
62 void *(*current_impl)(void const *); 64 void *(*current_impl)(void const *);
63 65
64 /** 66 /**
65 * Advances the iterator. 67 * Advances the iterator.
68 *
69 * When valid returns false, the behavior of this function is undefined.
66 */ 70 */
67 __attribute__ ((__nonnull__)) 71 __attribute__ ((__nonnull__))
68 void (*next)(void *); 72 void (*next)(void *);
69 73
70 /** 74 /**
71 * Flag current element for removal, if possible. 75 * Flag current element for removal, if possible.
76 *
77 * When valid returns false, the behavior of this function is undefined.
72 */ 78 */
73 __attribute__ ((__nonnull__)) 79 __attribute__ ((__nonnull__))
74 bool (*flag_removal)(void *); 80 bool (*flag_removal)(void *);
75 81
76 /** 82 /**
196 size_t index; 202 size_t index;
197 }; 203 };
198 204
199 /** 205 /**
200 * Iterator value type. 206 * Iterator value type.
201 * An iterator points to a certain element in an (possibly unbounded) chain of elements. 207 * An iterator points to a certain element in a (possibly unbounded) chain of elements.
202 * Iterators that are based on collections (which have a defined "first" element), are supposed 208 * Iterators that are based on collections (which have a defined "first" element), are supposed
203 * to be "position-aware", which means that they keep track of the current index within the collection. 209 * to be "position-aware", which means that they keep track of the current index within the collection.
204 * 210 *
205 * @note Objects that are pointed to by an iterator are always mutable through that iterator. However, 211 * @note Objects that are pointed to by an iterator are always mutable through that iterator. However,
206 * this iterator cannot mutate the collection itself (add or remove elements) and any mutation of the 212 * this iterator cannot mutate the collection itself (add or remove elements) and any mutation of the
207 * collection by other means make this iterator invalid (regardless of what cxIteratorValid() returns). 213 * collection by other means makes this iterator invalid (regardless of what cxIteratorValid() returns).
208 * 214 *
209 * @see CxMutIterator 215 * @see CxMutIterator
210 */ 216 */
211 typedef struct cx_iterator_s CxIterator; 217 typedef struct cx_iterator_s CxIterator;
212 218

mercurial