change fonctions pour list avec nouvelles fonctions pour listes a deux sens

This commit is contained in:
hugogogo
2022-03-24 16:49:59 +01:00
parent bc53060626
commit 60af4e44b0
27 changed files with 484 additions and 13 deletions

34
srcs/ft_lstcopy.c Normal file
View File

@@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstcopy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: simplonco <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/24 16:26:27 by simplonco #+# #+# */
/* Updated: 2022/03/24 16:37:39 by simplonco ### ########.fr */
/* */
/* ************************************************************************** */
/*
* copy a two-way list with the copy function for the content
* and return pointer to the begining of the new list
*/
#include "libft.h"
t_list *ft_lstcopy(t_list *lst, void *(*cpy)(void *))
{
t_list *lst_copy;
if (!lst || !cpy)
return (NULL);
lst_copy = NULL;
while (lst)
{
ft_lstpush_back(&lst_copy, ft_lstcreate(cpy(lst->content)));
lst = lst->next;
}
return (ft_lstbegin(lst_copy));
}