1 # Iterators |
1 # Iterators |
2 |
2 |
3 <warning> |
3 <warning> |
4 Outdated - Rewrite! |
4 Outdated Section - will be updated soon! |
5 </warning> |
5 </warning> |
6 |
6 |
7 In UCX 3 a new feature has been introduced to write own iterators, that work with the `cx_foreach` macro. |
7 In UCX 3 a new feature has been introduced to write own iterators, that work with the `cx_foreach` macro. |
8 In previous UCX releases there were different hard-coded foreach macros for lists and maps that were not customizable. |
8 In previous UCX releases there were different hard-coded foreach macros for lists and maps that were not customizable. |
9 Now, creating an iterator is as simple as creating a `CxIterator` struct and setting the fields in a meaningful way. |
9 Now, creating an iterator is as simple as creating a `CxIterator` struct and setting the fields in a meaningful way. |
22 The only differences are, that the `mutating` flag is `true` and the `src_handle` is not const. |
22 The only differences are, that the `mutating` flag is `true` and the `src_handle` is not const. |
23 On mutating iterators it is allowed to call the `cxFlagForRemoval()` function, which instructs the iterator to remove |
23 On mutating iterators it is allowed to call the `cxFlagForRemoval()` function, which instructs the iterator to remove |
24 the current element from the collection on the next call to `cxIteratorNext()` and clear the flag afterward. |
24 the current element from the collection on the next call to `cxIteratorNext()` and clear the flag afterward. |
25 If you are implementing your own iterator, it is up to you to implement this behavior. |
25 If you are implementing your own iterator, it is up to you to implement this behavior. |
26 |
26 |
|
27 <!-- |
27 ## Undocumented Symbols (TODO) |
28 ## Undocumented Symbols (TODO) |
28 ### cxIterator |
29 ### cxIterator |
29 ### cxIteratorPtr |
30 ### cxIteratorPtr |
30 ### cxMutIterator |
31 ### cxMutIterator |
31 ### cxMutIteratorPtr |
32 ### cxMutIteratorPtr |
|
33 --> |
|
34 |
|
35 <seealso> |
|
36 <category ref="apidoc"> |
|
37 <a href="https://ucx.sourceforge.io/api/iterator_8h.html">iterator.h</a> |
|
38 </category> |
|
39 </seealso> |