ucx
UAP Common Extensions
Loading...
Searching...
No Matches
Data Fields
cx_tree_iterator_s Struct Reference

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.
 
};  
 

Detailed Description

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.

Note
Objects that are pointed to by an iterator are mutable through that iterator. However, if the underlying data structure is mutated by other means than this iterator (e.g. elements added or removed), the iterator becomes invalid (regardless of what cxIteratorValid() returns).
See also
CxIterator

Field Documentation

◆ node

void* cx_tree_iterator_s::node

The currently observed node.

This is the same what cxIteratorCurrent() would return.

◆ node_next

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.

◆ stack

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().


The documentation for this struct was generated from the following file: