diff -r 1aa21afb8763 -r 56e76fbac167 docs/Writerside/topics/iterator.h.md --- a/docs/Writerside/topics/iterator.h.md Tue Dec 30 13:50:55 2025 +0100 +++ b/docs/Writerside/topics/iterator.h.md Tue Dec 30 21:44:23 2025 +0100 @@ -92,28 +92,6 @@ the current element from the collection on the next call to `cxIteratorNext()`. If you are implementing your own iterator, it is up to you to implement this behavior. -## Passing Iterators to Functions - -To eliminate the need of memory management for iterators, the structures are usually passed by value. -However, sometimes it is necessary to pass an iterator to another function. - -To make that possible in a generalized way, such functions should accept a `CxIteratorBase*` pointer -which can be obtained with the `cxIteratorRef()` macro on the calling site. - -In the following example, elements from a list are inserted into a tree: - -```C -CxList *list = // ... -CxTree *tree = // ... - -CxIterator iter = cxListIterator(list); -cxTreeInsertIter(tree, cxIteratorRef(iter), cxListSize(list)); -``` - -> This is the reason why `CX_ITERATOR_BASE` must be the first member of any iterator structure. -> Otherwise, the address taken by `cxIteratorRef()` would not equal the address of the iterator. -{style="note"} - ## Custom Iterators The base structure is defined as follows: