ft_lst.h
1 /* ************************************************************************** */ 2 /* */ 3 /* ::: :::::::: */ 4 /* ft_lst.h :+: :+: :+: */ 5 /* +:+ +:+ +:+ */ 6 /* By: ll-hotel <ll-hotel@student.42lyon.fr> +#+ +:+ +#+ */ 7 /* +#+#+#+#+#+ +#+ */ 8 /* Created: 2024/04/17 19:35:45 by ll-hotel #+# #+# */ 9 /* Updated: 2024/10/15 16:04:16 by ll-hotel ### ########.fr */ 10 /* */ 11 /* ************************************************************************** */ 12 13 #ifndef FT_LST_H 14 # define FT_LST_H 15 16 typedef struct s_lst_head t_lst_head; 17 typedef struct s_lst t_lst; 18 19 struct s_lst_head 20 { 21 union 22 { 23 t_lst *first; 24 t_lst_head *next; 25 }; 26 }; 27 28 struct s_lst 29 { 30 t_lst *next; 31 }; 32 33 void lst_add_back(t_lst_head *lst, t_lst *elt); 34 void lst_add_front(t_lst_head *lst, t_lst *elt); 35 void lst_clear(t_lst_head *lst, void (*f)(void *)); 36 void lst_delone(t_lst_head *lst, void (*f)(void *)); 37 long lst_len(t_lst_head *lst); 38 t_lst *lst_at(t_lst_head *lst, unsigned long i); 39 t_lst *lst_next(t_lst_head *lst); 40 t_lst *lst_last(t_lst_head *lst); 41 42 void lst_iter(t_lst_head *lst, void (*f)(void *)); 43 t_lst *lst_map(t_lst_head *lst, void *(*f)(void *), void (*del)(void *)); 44 45 #endif