-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_dlstiter.c
45 lines (40 loc) · 1.33 KB
/
ft_dlstiter.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlstiter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: phemsi-a <phemsi-a@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 18:39:37 by phemsi-a #+# #+# */
/* Updated: 2021/05/29 11:08:23 by phemsi-a ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_dlstiter(t_dlist *lst, void (*f)(int))
{
t_dlist *aux;
if (lst == NULL)
return ;
aux = lst;
while (aux != NULL)
{
f(aux->content);
ft_putchar('\n');
aux = aux->next;
}
}
void ft_dlstiter_reverse(t_dlist *lst, void (*f)(int))
{
t_dlist *aux;
if (lst == NULL)
return ;
aux = lst;
while (aux->next != NULL)
aux = aux->next;
while (aux != NULL)
{
f(aux->content);
ft_putchar('\n');
aux = aux->previous;
}
}