ndtree_node_t * ndtree_create_root(ndtree_t *tree, void *value)
Creates a new node and assigns it as root of the tree.
Definition: ndtree.c:107
ndtree_node_t * ndtree_iter_last(ndtree_node_t *node, ndtree_iter_t *iter)
Initializes the iterator the the last child of the node.
Definition: ndtree.c:346
ndtree_t * ndtree_tree_create(ndtree_tree_cmp_f cmp)
Allocate memory for a tree and sets the function used to compare nodes.
Definition: ndtree.c:159
void ndtree_tree_dealloc(ndtree_t *tree, ndtree_tree_node_f node_cb)
Deallocate a node.
Definition: ndtree.c:197
int ndtree_tree_remove_node_with_cb(ndtree_t *tree, ndtree_node_t *node, ndtree_tree_node_f node_cb)
Removes the node from the given tree.
Definition: ndtree.c:271
void ndtree_set_root(ndtree_t *tree, ndtree_node_t *node)
Sets the given node as root of the tree.
Definition: ndtree.c:101
ndtree_node_t * ndtree_iter_first(ndtree_node_t *node, ndtree_iter_t *iter)
Initializes the iterator the the first child of the node.
Definition: ndtree.c:334
int ndtree_tree_remove_with_cb(ndtree_t *tree, void *value, ndtree_tree_node_f node_cb)
Removes the node from the given tree.
Definition: ndtree.c:308
void ndtree_node_dealloc(ndtree_node_t *node)
Deallocate a node.
Definition: ndtree.c:145
void ndtree_node_set_value(ndtree_node_t *node, void *value)
Sets the value of the given node.
Definition: ndtree.c:86
ndtree_node_t * ndtree_node_init(ndtree_node_t *node, void *value)
Initializes the already allocated node.
Definition: ndtree.c:75
ndtree_node_t * ndtree_node_alloc(void)
Allocate memory for a node.
Definition: ndtree.c:63
unsigned int ndtree_node_count_children(ndtree_node_t *node)
Counts the number of children of the given node.
Definition: ndtree.c:133
void ndtree_add_child_to_node(ndtree_t *tree, ndtree_node_t *parent, ndtree_node_t *child)
Adds the given child as child of parent.
Definition: ndtree.c:119
ndtree_node_t * ndtree_iter_next(ndtree_iter_t *iter)
Moves the iterator to the next element.
Definition: ndtree.c:358
int(* ndtree_tree_cmp_f)(ndtree_t *tree, void *lhs, void *rhs)
Function for comparing elements in the tree.
Definition: ndtree.h:22
void ndtree_tree_visitor(ndtree_t *tree, ndtree_tree_node_f enter_fun, ndtree_tree_node_f exit_fun)
Run a visit of the tree (DFS).
Definition: ndtree.c:407
ndtree_t * ndtree_tree_alloc(void)
Allocate memory for a tree.
Definition: ndtree.c:154
ndtree_iter_t * ndtree_iter_alloc(void)
Allocate the memory for the iterator.
Definition: ndtree.c:319
ndtree_node_t * ndtree_get_root(ndtree_t *tree)
Provides access to the root of the tree.
Definition: ndtree.c:114
ndtree_node_t * ndtree_node_create(void *value)
Allocate memory for a node and sets its value.
Definition: ndtree.c:68
void ndtree_iter_dealloc(ndtree_iter_t *iter)
Deallocate the memory for the iterator.
Definition: ndtree.c:327
void(* ndtree_tree_node_f)(ndtree_t *tree, ndtree_node_t *node)
Callback to call on elements of the tree.
Definition: ndtree.h:24
ndtree_node_t * ndtree_tree_find(ndtree_t *tree, ndtree_tree_cmp_f cmp, void *value)
Searches the node inside the tree with the given value.
Definition: ndtree.c:230
ndtree_node_t * ndtree_create_child_of_node(ndtree_t *tree, ndtree_node_t *parent, void *value)
Creates a new node and sets it as child of parent.
Definition: ndtree.c:126
ndtree_node_t * ndtree_iter_prev(ndtree_iter_t *iter)
Moves the iterator to the previous element.
Definition: ndtree.c:369
ndtree_node_t * ndtree_node_find(ndtree_t *tree, ndtree_node_t *node, ndtree_tree_cmp_f cmp, void *value)
Searches the given value among the children of node.
Definition: ndtree.c:238
unsigned int ndtree_tree_size(ndtree_t *tree)
Returns the size of the tree.
Definition: ndtree.c:263
void * ndtree_node_get_value(ndtree_node_t *node)
Provides access to the value associated to a node.
Definition: ndtree.c:93
ndtree_t * ndtree_tree_init(ndtree_t *tree, ndtree_tree_cmp_f cmp)
Initializes the tree.
Definition: ndtree.c:164
Stores data about an NDTree iterator.
Definition: ndtree.c:40
Stores data about an NDTree node.
Definition: ndtree.c:16
Stores data about an NDTree.
Definition: ndtree.c:28