| 294 #define cxTreeVisitorContinue(visitor) |
294 #define cxTreeVisitorContinue(visitor) |
| 295 |
295 |
| 296 void cxTreeVisitorDispose(CxTreeVisitor *visitor); |
296 void cxTreeVisitorDispose(CxTreeVisitor *visitor); |
| 297 ``` |
297 ``` |
| 298 |
298 |
| 299 <warning> |
299 There are two different kind of iterators for trees. |
| 300 TODO: document |
300 The `CxTreeIterator` is performing a depth-first iteration with the capability of visiting a node twice: |
| 301 </warning> |
301 first when the iterator enters the node coming from its parent, and secondly when the iterator tracks back from its last child. |
| |
302 On the other hand, the `CxTreeVisitor` performs a breadth-first iteration and visits every node only once. |
| |
303 |
| |
304 Since tree iteration needs to keep track of a stack (depth-first) or queue (breadth-frist), internal memory is allocated. |
| |
305 This memory is _automatically_ disposed when the iteration _completes_. |
| |
306 If you break from the iteration early, you must call `cxTreeIteratorDispose()` or `cxTreeVisitorDispose()`, respectively, to deallocate the memory. |
| |
307 |
| |
308 > It is strongly recommended to always invoke the dispose functions, even when it seems not necessary. |
| |
309 > In the best case it just does nothing, but calling them guarantees that no memory can be leaking. |
| |
310 >{style="note"} |
| |
311 |
| 302 |
312 |
| 303 ## Remove |
313 ## Remove |
| 304 |
314 |
| 305 ```C |
315 ```C |
| 306 #include <cx/tree.h> |
316 #include <cx/tree.h> |