|
|
#define | INIT_TREE_NODE(_node) |
| | Initialize an empty tree node.
|
| |
| #define | FOREACH_CHILDREN(_iter, _node) FOREACH_LLIST (_iter, &(_node)->children) |
| | Loop over each children of a tree node. More...
|
| |
|
|
typedef tree_node_t * | tree_t |
| | The root of a tree structure.
|
| |
Tree
This is our implementation of an intrusive generic tree structure.
◆ FOREACH_CHILDREN
| #define FOREACH_CHILDREN |
( |
|
_iter, |
|
|
|
_node |
|
) |
| FOREACH_LLIST (_iter, &(_node)->children) |
- Parameters
-
| _iter | The name of the iterator used inside the loop |
| _node | The tree node |
◆ tree_add_child()
- Note
- This function appends the new child to the current list of children. If you want to keep the children sorted use tree_add_child_sorted
◆ tree_add_child_sorted()
- Warning
- This function assumes that the node's children are already sorted
- Parameters
-
| node | The parent node |
| child | The new child |
| compare | The compare function used on the children |
◆ tree_find_child()
- Parameters
-
| node | The parent node |
| compare | The compare function used to find the node |
| data | Data passed to the compare function |
- Returns
- The child or
NULL
◆ tree_free()
- Parameters
-
| root | The root of the tree |
| free | The function used to free an element |
◆ tree_node()
Children of a node are linked together and addressed using a likned list, it is necessary (and trivial) to perform this conversion when iterating over them.
◆ tree_remove()