lstiter better usage

This commit is contained in:
Jack Halford 2017-03-11 18:33:39 +01:00
parent f90983da4d
commit 7c0741ea60
3 changed files with 8 additions and 6 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */
/* Updated: 2017/03/08 11:58:26 by jhalford ### ########.fr */
/* Updated: 2017/03/11 16:18:00 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -31,7 +31,7 @@ t_list *ft_lstnew(void const *content, size_t content_size);
void ft_lstdel(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_lstiter(t_list *lst, void (*f)(t_list *elem));
int ft_lstiter(t_list *lst, int (*f)());
t_list *ft_lstmap(t_list *lst, void *(*f)(void *));
t_list *ft_lstnew_range(int a, int b);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
/* Updated: 2017/03/11 13:14:24 by jhalford ### ########.fr */
/* Updated: 2017/03/11 18:17:48 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,17 +6,19 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:19 by jhalford #+# #+# */
/* Updated: 2016/12/12 13:31:59 by jhalford ### ########.fr */
/* Updated: 2017/03/11 16:17:43 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstiter(t_list *lst, void (*f)(t_list *elem))
int ft_lstiter(t_list *lst, int (*f)())
{
while (lst)
{
(*f)(lst);
if ((*f)(lst->content))
return (1);
lst = lst->next;
}
return (0);
}