![]() |
ucx
UAP Common Extensions
|
A depth-first tree iterator. More...
#include <tree.h>
Data Fields | ||
struct cx_iterator_base_s | base | |
Base members. | ||
bool | skip | |
Indicates whether the subtree below the current node shall be skipped. | ||
bool | visit_on_exit | |
Set to true, when the iterator shall visit a node again when all it's children have been processed. | ||
bool | exiting | |
True, if this iterator is currently leaving the node. | ||
ptrdiff_t | loc_children | |
Offset in the node struct for the children linked list. | ||
ptrdiff_t | loc_next | |
Offset in the node struct for the next pointer. | ||
size_t | counter | |
The total number of distinct nodes that have been passed so far. | ||
void * | node | |
The currently observed node. | ||
void * | node_next | |
Stores a copy of the next pointer of the visited node. | ||
void ** | stack | |
Internal stack. | ||
size_t | stack_capacity | |
Internal capacity of the stack. | ||
union { | ||
size_t stack_size | ||
Internal stack size. | ||
size_t depth | ||
The current depth in the tree. | ||
}; | ||
A depth-first tree iterator.
This iterator is not position-aware in a strict sense, as it does not assume a particular order of elements in the tree. However, the iterator keeps track of the number of nodes it has passed in a counter variable. Each node, regardless of the number of passes, is counted only once.
void* cx_tree_iterator_s::node |
The currently observed node.
This is the same what cxIteratorCurrent() would return.
void* cx_tree_iterator_s::node_next |
Stores a copy of the next pointer of the visited node.
Allows freeing a node on exit without corrupting the iteration.
void** cx_tree_iterator_s::stack |
Internal stack.
Will be automatically freed once the iterator becomes invalid.
If you want to discard the iterator before, you need to manually call cxTreeIteratorDispose().