LST functions. More...
Functions | |
t_list * | ft_lstnew (void *content) |
Allocate (with malloc(3)) and return a new element. The variable member 'content' is initialized with the value of the parameter 'content'. The variable 'next' is initialized to NULL. | |
void | ft_lstadd_front (t_list **lst, t_list *new) |
Adds the element ’new’ at the start of the list. | |
int | ft_lstsize (t_list *lst) |
Count the number of elements in a list. | |
t_list * | ft_lstlast (t_list *lst) |
Returns the last element of the list. | |
void | ft_lstadd_back (t_list **lst, t_list *new) |
Adds the element ’new’ at the end of the list. | |
void | ft_lstdelone (t_list *lst, void(*del)(void *)) |
Free the memory of the element passed as a parameter using the function 'del' and free(3). The memory of next must not be freed. | |
void | ft_lstclear (t_list **lst, void(*del)(void *)) |
Deletes and free the memory of the element passed as a parameter, and all the elements that follow, using 'del' and free(3) Finally, the initial pointer must be set to NULL. | |
void | ft_lstiter (t_list *lst, void(*f)(void *)) |
Iterate on the linked list 'lst' and apply the function 'f' on the content of each element. | |
t_list * | ft_lstmap (t_list *lst, void *(*f)(void *), void(*del)(void *)) |
Iterated on the linked list 'list' and apply the function 'f' on the content of each element. Create a new list resulting from the successive applications of 'f'. The function 'del' is there to destroy the content of an element if necessary. | |
void | ft_swap_nodes (t_list **start, t_list *lst1, t_list *lst2) |
Swap two nodes in a linked list (swap nodes, not content) | |
LST functions.
Adds the element ’new’ at the end of the list.
lst | head of the linked list |
new | new node to add |
Adds the element ’new’ at the start of the list.
lst | head of the linked list |
new | new node to add |
void ft_lstclear | ( | t_list ** | lst, |
void(* | del )(void *) ) |
Deletes and free the memory of the element passed as a parameter, and all the elements that follow, using 'del' and free(3) Finally, the initial pointer must be set to NULL.
lst | head of the linked list |
del | function to apply to delete all the content of the element |
void ft_lstdelone | ( | t_list * | lst, |
void(* | del )(void *) ) |
Free the memory of the element passed as a parameter using the function 'del' and free(3). The memory of next must not be freed.
lst | head of the linked list |
del | function to apply to delete all the content of the element |
void ft_lstiter | ( | t_list * | lst, |
void(* | f )(void *) ) |
Iterate on the linked list 'lst' and apply the function 'f' on the content of each element.
lst | head of the linked list |
f | function to apply to the content of each element |
Returns the last element of the list.
lst | head of the linked list |
Iterated on the linked list 'list' and apply the function 'f' on the content of each element. Create a new list resulting from the successive applications of 'f'. The function 'del' is there to destroy the content of an element if necessary.
lst | head of the linked list |
f | function to apply to the content of each element |
del | function to apply to delete all the content of the element |
t_list * ft_lstnew | ( | void * | content | ) |
Allocate (with malloc(3)) and return a new element. The variable member 'content' is initialized with the value of the parameter 'content'. The variable 'next' is initialized to NULL.
content | content to add to the new element |
int ft_lstsize | ( | t_list * | lst | ) |
Count the number of elements in a list.
lst | list to count |