|
ucx
UAP Common Extensions
|
An iterator (DFS) or visitor (BFS) for a tree. More...
#include <tree.h>
Data Fields | ||
| struct cx_iterator_base_s | base | |
| Base members. | ||
| 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. | ||
| size_t | depth | |
| The current depth in the tree. | ||
| void * | node | |
| The currently observed node. | ||
| union { | ||
| struct { | ||
| void * node_next | ||
| Stores a copy of the pointer to the successor of the visited node. More... | ||
| void ** stack | ||
| Internal stack. More... | ||
| size_t stack_capacity | ||
| Internal capacity of the stack. | ||
| } | ||
| struct { | ||
| struct cx_tree_visitor_queue_s * queue_next | ||
| The next element in the visitor queue. | ||
| struct cx_tree_visitor_queue_s * queue_last | ||
| The last element in the visitor queue. | ||
| } | ||
| }; | ||
| Memory for BFS or DFS-specific data. | ||
| 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 its children have been processed. | ||
| bool | exiting | |
| True, if this iterator is currently leaving the node. | ||
| bool | use_dfs | |
Indicates whether the iterator (true) or the visitor (false) aspect is active. | ||
An iterator (DFS) or visitor (BFS) for a tree.
| size_t cx_tree_combined_iterator_s::counter |
The total number of distinct nodes that have been passed so far.
This includes the currently visited node.
| void* cx_tree_combined_iterator_s::node |
The currently observed node.
This is the same what cxIteratorCurrent() would return.
| void* cx_tree_combined_iterator_s::node_next |
Stores a copy of the pointer to the successor of the visited node.
Allows freeing a node on exit without corrupting the iteration.
| void** cx_tree_combined_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().