docs/Writerside/topics/iterator.h.md

changeset 1432
fb82e7a92258
parent 1429
6e0c3a8a914a
equal deleted inserted replaced
1431:1ec36e652e57 1432:fb82e7a92258
117 117
118 The base structure is defined as follows: 118 The base structure is defined as follows:
119 ```C 119 ```C
120 struct cx_iterator_base_s { 120 struct cx_iterator_base_s {
121 bool (*valid)(const void *); 121 bool (*valid)(const void *);
122 bool (*valid_impl)(const void *);
122 void *(*current)(const void *); 123 void *(*current)(const void *);
123 void (*next)(void *); 124 void (*next)(void *);
124 void *(*current_impl)(const void *); 125 void *(*current_impl)(const void *);
125 void (*next_impl)(void *); 126 void (*next_impl)(void *);
126 bool allow_remove; 127 bool allow_remove;
136 137
137 The booleans `allow_remove` and `remove` are used for [removing elements](#removing-elements-via-iterators) as explained above. 138 The booleans `allow_remove` and `remove` are used for [removing elements](#removing-elements-via-iterators) as explained above.
138 When an iterator is created, the `allow_remove` field is set to indicate if removal of elements is supported. 139 When an iterator is created, the `allow_remove` field is set to indicate if removal of elements is supported.
139 The `remove` field is set to indicate if the current element should be removed on the next call to `next()` (see `cxIteratorFlagRemoval()`). 140 The `remove` field is set to indicate if the current element should be removed on the next call to `next()` (see `cxIteratorFlagRemoval()`).
140 141
141 Iterators may be wrapped in which case the original implementation can be stored in `current_impl` and `next_impl`. 142 Iterators may be wrapped in which case the original implementation can be stored in the `*_impl` function pointers.
142 They can then be called by a wrapper implementation pointed to by `current` and `next`, respectively. 143 They can then be called by a wrapper implementation pointed to by `current` and `next`, respectively.
143 This can be useful when you want to support the `store_pointer` field of the [](collection.h.md) API. 144 This can be useful when you want to support the `store_pointer` field of the [](collection.h.md) API.
144 145
145 A specialized, simple, and fast iterator over an array of a certain type 146 A specialized, simple, and fast iterator over an array of a certain type
146 that does not support removing elements can be implemented as follows: 147 that does not support removing elements can be implemented as follows:

mercurial