|
Libft
Custom implementation of core libc functions with additional utility helpers.
|
Doubly linked list utilities. More...
Functions | |
| t_node * | node_new (void *content, t_node *prev, t_node *next) |
| Creates a new list node. | |
| void | node_free (t_node **node, void(*del_content)(void *)) |
| Frees a node and optionally its content. | |
| bool | list_add_end (t_list *list, void *new_content) |
| Adds a new element at the end of the list. | |
| bool | list_add_start (t_list *list, void *new_content) |
| Adds a new element at the start of the list. | |
| size_t | list_get_size (t_list list) |
| Calculates the number of nodes in the list. | |
| void * | list_get_content (t_list list, bool(*select_function)(void *)) |
| Finds content in list matching a selection function. | |
| void * | list_get_content_n (t_list list, size_t index) |
| Gets content at a specific index in the list. | |
| void * | list_get_content_last (t_list list) |
| Gets the content of the last node in the list. | |
| t_node * | list_get_node_n (t_list list, size_t index) |
| Gets the node at a specific index in the list. | |
| t_node * | list_get_node_last (t_list list) |
| Gets the last node in the list. | |
| void | list_iter (t_list lst, void(*f)(void *)) |
| Applies a function to each element of the list. | |
| t_list | list_map (t_list list, void *(*f)(void *), void(*del)(void *)) |
| Creates a new list by applying a function to each element. | |
| void | list_rm (t_list *list, t_node *node, void(*del_content)(void *)) |
| Removes a specific node from the list. | |
| void | list_rm_all (t_list *list, void(*del_content)(void *)) |
| Removes all nodes from the list. | |
Doubly linked list utilities.
Functions to create, manipulate and traverse doubly linked lists.
| bool list_add_end | ( | t_list * | list, |
| void * | new_content ) |
Adds a new element at the end of the list.
| list | Pointer to the list pointer (borrowed). |
| new_content | Content for the new node (ownership transferred). |


| bool list_add_start | ( | t_list * | list, |
| void * | new_content ) |
Adds a new element at the start of the list.
| list | Pointer to the list pointer (borrowed). |
| new_content | Content for the new node (ownership transferred). |

| void * list_get_content | ( | t_list | list, |
| bool(* | select_function )(void *) ) |
Finds content in list matching a selection function.
| list | List to search (borrowed). |
| select_function | Function returning true for desired content. |
| void * list_get_content_last | ( | t_list | list | ) |
Gets the content of the last node in the list.
| list | List to search (borrowed). |

| void * list_get_content_n | ( | t_list | list, |
| size_t | index ) |
Gets content at a specific index in the list.
| list | List to search (borrowed). |
| index | Zero-based index. |

Gets the last node in the list.
| list | List to search (borrowed). |

Gets the node at a specific index in the list.
| list | List to search (borrowed). |
| index | Zero-based index. |

| size_t list_get_size | ( | t_list | list | ) |
Calculates the number of nodes in the list.
| list | List to count. |
| void list_iter | ( | t_list | lst, |
| void(* | f )(void *) ) |
Applies a function to each element of the list.
| lst | List to iterate over (borrowed). |
| f | Function to apply to each element's content. |
Creates a new list by applying a function to each element.
| list | Source list (borrowed). |
| f | Function to apply to each element (returns new content, owned). |
| del | Function to delete content on failure. |

Removes a specific node from the list.
| list | Pointer to the list pointer (borrowed). |
| node | Node to remove (ownership taken, will be freed). |
| del_content | Function to delete the node's content (can be NULL). |

| void list_rm_all | ( | t_list * | list, |
| void(* | del_content )(void *) ) |
Removes all nodes from the list.
| list | Pointer to the list pointer (set to NULL after). |
| del_content | Function to delete each node's content (can be NULL). |

| void node_free | ( | t_node ** | node, |
| void(* | del_content )(void *) ) |
Frees a node and optionally its content.
| node | Pointer to the node pointer (set to NULL after freeing). |
| del_content | Function to delete the content (can be NULL to skip). |
Creates a new list node.
| content | Content for the new node (ownership transferred). |
| prev | Pointer to the previous node (borrowed, can be NULL). |
| next | Pointer to the next node (borrowed, can be NULL). |
