|
Libft
Custom implementation of core libc functions with additional utility helpers.
|
Binary tree node utilities. More...
Functions | |
| t_btree_node * | btree_new (void *data) |
| Creates a new binary tree node. | |
| void | btree_set_left (t_btree_node *parent, t_btree_node *child) |
| Sets the left child of a parent node. | |
| void | btree_set_right (t_btree_node *parent, t_btree_node *child) |
| Sets the right child of a parent node. | |
| t_btree_node * | btree_detach_left (t_btree_node *parent) |
| Detaches and returns the left child of a parent node. | |
| t_btree_node * | btree_detach_right (t_btree_node *parent) |
| Detaches and returns the right child of a parent node. | |
| void | btree_free (t_btree_node **node, void(*data_free)(void *data)) |
| Recursively frees a node and its descendants. | |
Binary tree node utilities.
Functions to create, link, detach and recursively free binary tree nodes.
| t_btree_node * btree_detach_left | ( | t_btree_node * | parent | ) |
Detaches and returns the left child of a parent node.
Updates both parent->left and the detached child's parent pointer to NULL.
| parent | Parent node to detach from (borrowed). |
| t_btree_node * btree_detach_right | ( | t_btree_node * | parent | ) |
Detaches and returns the right child of a parent node.
Updates both parent->right and the detached child's parent pointer to NULL.
| parent | Parent node to detach from (borrowed). |
| void btree_free | ( | t_btree_node ** | node, |
| void(*)(void *data) | data_free | ||
| ) |
Recursively frees a node and its descendants.
Performs a post-order traversal and frees each node. If data_free is provided, it is called for each non-NULL node payload before node free.
| node | Pointer to the root node pointer (set to NULL after freeing). |
| data_free | Optional payload destructor (can be NULL). |


| t_btree_node * btree_new | ( | void * | data | ) |
Creates a new binary tree node.
| data | Payload for the new node (ownership transferred on success). |
| void btree_set_left | ( | t_btree_node * | parent, |
| t_btree_node * | child | ||
| ) |
Sets the left child of a parent node.
Links child under parent and updates child->parent accordingly.
| parent | Parent node to update (borrowed). |
| child | Child node to attach as left child (borrowed). |
| void btree_set_right | ( | t_btree_node * | parent, |
| t_btree_node * | child | ||
| ) |
Sets the right child of a parent node.
Links child under parent and updates child->parent accordingly.
| parent | Parent node to update (borrowed). |
| child | Child node to attach as right child (borrowed). |