|
GRU - Generic Reusable Utilities
|
#include "gru_tree.h"Data Structures | |
| struct | gru_tree_node_wrapper_t_ |
Typedefs | |
| typedef struct gru_tree_node_wrapper_t_ | gru_tree_wrapper_t |
Functions | |
| gru_tree_node_t * | gru_tree_new (const void *data) |
| Creates a new tree and returns a pointer to the root node. More... | |
| void | gru_tree_destroy (gru_tree_node_t **ptr) |
| Destroys a tree node and all it's descendants. More... | |
| gru_tree_node_t * | gru_tree_add_child (gru_tree_node_t *node, const void *data) |
| Adds a child node to a given node. More... | |
| const gru_tree_node_t * | gru_tree_search (gru_tree_node_t *node, compare_function_t comparable, const void *other) |
| Searches the tree using DFS. More... | |
| bool | gru_tree_remove_child (gru_tree_node_t *node, compare_function_t comparable, const void *other) |
| Removes a direct descendant of a node. More... | |
| const gru_tree_node_t * | gru_tree_for_each (gru_tree_node_t *node, tree_callback_fn callback, void *payload) |
| Traverses the tree executing a set of operations. More... | |
| void | gru_tree_for_each_child (gru_tree_node_t *node, tree_callback_fn callback, void *payload) |
| Executes an operation on each child of the given node. More... | |
| uint32_t | gru_tree_count_children (gru_tree_node_t *node) |
| Returns the number of children of a node. More... | |
| uint32_t | gru_tree_count (gru_tree_node_t *node) |
| Returns the number of children of a tree. More... | |
| const gru_tree_node_t * | gru_tree_search_child (gru_tree_node_t *node, compare_function_t comparable, const void *other) |
| Searches only the immediate children of the node. More... | |
| typedef struct gru_tree_node_wrapper_t_ gru_tree_wrapper_t |
| gru_tree_node_t * gru_tree_add_child | ( | gru_tree_node_t * | node, |
| const void * | data | ||
| ) |
Adds a child node to a given node.
| node | The node to add the child to |
| data | The data to add to the child |
| uint32_t gru_tree_count | ( | gru_tree_node_t * | node | ) |
Returns the number of children of a tree.
| node | The node to count the number of children |
| uint32_t gru_tree_count_children | ( | gru_tree_node_t * | node | ) |
Returns the number of children of a node.
| node | The node to count the number of children |
| void gru_tree_destroy | ( | gru_tree_node_t ** | ptr | ) |
Destroys a tree node and all it's descendants.
| ptr | A pointer-to-pointer for the node to destroy |
| const gru_tree_node_t * gru_tree_for_each | ( | gru_tree_node_t * | node, |
| tree_callback_fn | callback, | ||
| void * | payload | ||
| ) |
Traverses the tree executing a set of operations.
| node | The starting node for the search |
| callback | A callback function to be executed for all the nodes |
| payload | Payload data to be passed to the passed to the callback |
| void gru_tree_for_each_child | ( | gru_tree_node_t * | node, |
| tree_callback_fn | callback, | ||
| void * | payload | ||
| ) |
Executes an operation on each child of the given node.
| node | The starting node for the search |
| callback | A callback function to be executed for all the nodes |
| payload | Payload data to be passed to the passed to the callback |
| gru_tree_node_t * gru_tree_new | ( | const void * | data | ) |
Creates a new tree and returns a pointer to the root node.
| data | The data for the root node |
| bool gru_tree_remove_child | ( | gru_tree_node_t * | node, |
| compare_function_t | comparable, | ||
| const void * | other | ||
| ) |
Removes a direct descendant of a node.
| node | The parent node |
| comparable | A comparator function |
| other | The data to compare to |
| const gru_tree_node_t * gru_tree_search | ( | gru_tree_node_t * | node, |
| compare_function_t | comparable, | ||
| const void * | other | ||
| ) |
Searches the tree using DFS.
| node | The starting node for the search |
| comparable | A comparator function |
| other | The data to compare to |
| const gru_tree_node_t * gru_tree_search_child | ( | gru_tree_node_t * | node, |
| compare_function_t | comparable, | ||
| const void * | other | ||
| ) |
Searches only the immediate children of the node.
| node | The starting node for the search |
| comparable | A comparator function |
| other | The data to compare to |