lstmap change like btree_map
This commit is contained in:
parent
a10ad36cbf
commit
829740fdea
6 changed files with 34 additions and 15 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:21:04 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:21:04 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/07 13:21:52 by jhalford ### ########.fr */
|
/* Updated: 2017/03/07 17:25:50 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/07 14:54:00 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 11:57:34 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/03 13:36:18 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 11:56:43 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ void ft_lstdel(t_list **alst, void (*del)(void *, size_t));
|
||||||
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t));
|
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t));
|
||||||
void ft_lstadd(t_list **alst, t_list *new);
|
void ft_lstadd(t_list **alst, t_list *new);
|
||||||
void ft_lstiter(t_list *lst, void (*f)(t_list *elem));
|
void ft_lstiter(t_list *lst, void (*f)(t_list *elem));
|
||||||
t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem));
|
t_list *ft_lstmap(t_list *lst, void *(*f)(void *));
|
||||||
|
|
||||||
t_list *ft_lstnew_range(int a, int b);
|
t_list *ft_lstnew_range(int a, int b);
|
||||||
void ft_lsteadd(t_list **alst, t_list *new);
|
void ft_lsteadd(t_list **alst, t_list *new);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* btree_map.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/08 11:50:46 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2017/03/08 11:53:47 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "btree.h"
|
#include "btree.h"
|
||||||
|
|
||||||
t_btree *btree_map(t_btree *root, void *(*f)(void *))
|
t_btree *btree_map(t_btree *root, void *(*f)(void *))
|
||||||
|
|
|
||||||
|
|
@ -6,24 +6,19 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 14:57:21 by jhalford #+# #+# */
|
/* Created: 2016/11/03 14:57:21 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/02 17:48:58 by jhalford ### ########.fr */
|
/* Updated: 2017/03/08 11:57:03 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
|
t_list *ft_lstmap(t_list *lst, void *(*f)(void *))
|
||||||
{
|
{
|
||||||
t_list *out;
|
t_list *out;
|
||||||
t_list *elem;
|
t_list *elem;
|
||||||
|
|
||||||
out = NULL;
|
elem = ft_lstnew(lst->content, lst->content_size);
|
||||||
while (lst)
|
|
||||||
{
|
|
||||||
elem = (*f)(lst);
|
elem = (*f)(lst);
|
||||||
elem = ft_lstnew(elem->content, elem->content_size);
|
elem->next = ft_lstmap(lst->next, f);
|
||||||
ft_lsteadd(&out, elem);
|
return (elem);
|
||||||
lst = lst->next;
|
|
||||||
}
|
|
||||||
return (out);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strtok.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/07 18:08:31 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2017/03/07 18:18:30 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
char *ft_strtok(char *s, const char *delim)
|
char *ft_strtok(char *s, const char *delim)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue