some name changes
This commit is contained in:
parent
258a00cfeb
commit
e590988c7d
7 changed files with 56 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#include "libft.h"
|
||||
|
||||
void *ft_id(void *a)
|
||||
t_list *ft_id(t_list *a)
|
||||
{
|
||||
return (a);
|
||||
}
|
||||
|
|
|
|||
8
libft/ft_lst_cfree.c
Normal file
8
libft/ft_lst_cfree.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include "libft.h"
|
||||
|
||||
void ft_lst_cfree(void *ptr, size_t size)
|
||||
{
|
||||
(void)size;
|
||||
if (ptr)
|
||||
free(ptr);
|
||||
}
|
||||
|
|
@ -1,29 +1,25 @@
|
|||
#include "libft.h"
|
||||
|
||||
void ft_lst_remove_if(
|
||||
t_list **begin_list,
|
||||
void *data_ref,
|
||||
int (*cmp)())
|
||||
void ft_lst_delif(t_list **alst, void *data_ref, int (*cmp)(), void (*del)(void *, size_t))
|
||||
{
|
||||
t_list *last;
|
||||
t_list *current;
|
||||
t_list *tmp;
|
||||
|
||||
last = NULL;
|
||||
current = *begin_list;
|
||||
current = *alst;
|
||||
tmp = NULL;
|
||||
fflush(stdout);
|
||||
while (current)
|
||||
{
|
||||
if ((*cmp)(current->content, &data_ref) == 0)
|
||||
if ((*cmp)(current->content, data_ref) == 0)
|
||||
{
|
||||
if (current == *begin_list)
|
||||
*begin_list = current->next;
|
||||
if (current == *alst)
|
||||
*alst = current->next;
|
||||
else
|
||||
last->next = current->next;
|
||||
tmp = current;
|
||||
current = current->next;
|
||||
free(tmp);
|
||||
ft_lstdelone(&tmp, del);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#include "libft.h"
|
||||
|
||||
void ft_lstdelsub(t_list **alst, t_list *sub, int (*cmp)(), void (*del)(void *, size_t))
|
||||
void ft_lst_delsub(t_list **alst, t_list *sub, int (*cmp)(), void (*del)(void *, size_t))
|
||||
{
|
||||
t_list *last;
|
||||
t_list *current;
|
||||
|
|
@ -11,6 +11,11 @@ void ft_lstdelsub(t_list **alst, t_list *sub, int (*cmp)(), void (*del)(void *,
|
|||
tmp = NULL;
|
||||
while (current && sub)
|
||||
{
|
||||
if ((*cmp)(current->content, sub->content) > 0)
|
||||
{
|
||||
sub = sub->next;
|
||||
continue ;
|
||||
}
|
||||
if ((*cmp)(current->content, sub->content) == 0)
|
||||
{
|
||||
if (current == *alst)
|
||||
24
libft/ft_lst_filter.c
Normal file
24
libft/ft_lst_filter.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "libft.h"
|
||||
|
||||
t_list *ft_lst_filter(t_list *lst, void const *data_ref, t_list *(*f)(t_list *elem, void const *))
|
||||
{
|
||||
t_list *out;
|
||||
t_list *elem;
|
||||
|
||||
out = NULL;
|
||||
while (lst)
|
||||
{
|
||||
elem = (*f)(lst, data_ref);
|
||||
/* printf("size=%zu\n", elem->content_size); */
|
||||
/* printf("content=%i\n", *(int*)elem->content); */
|
||||
/* fflush(stdout); */
|
||||
elem = ft_lstnew(elem->content, elem->content_size);
|
||||
/* printf("size=%zu\n", elem->content_size); */
|
||||
/* printf("content=%i\n", *(int*)elem->content); */
|
||||
/* fflush(stdout); */
|
||||
ft_lsteadd(&out, elem);
|
||||
lst = lst->next;
|
||||
}
|
||||
/* ft_lst_print(out, &ft_putnbr); */
|
||||
return (out);
|
||||
}
|
||||
|
|
@ -2,7 +2,11 @@
|
|||
|
||||
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t))
|
||||
{
|
||||
if (*alst)
|
||||
{
|
||||
if (del)
|
||||
(*del)((*alst)->content, (*alst)->content_size);
|
||||
free(*alst);
|
||||
}
|
||||
*alst = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,11 @@ t_list *ft_lstlast(t_list *lst);
|
|||
void ft_lst_sorted_merge(t_list **begin_list1, t_list *begin_list2, int (*cmp)());
|
||||
void ft_lst_sorted_insert(t_list **begin_list, t_list *insert, int (*cmp)());
|
||||
t_list *ft_lstnew_range(int a, int b);
|
||||
void ft_lst_delif(t_list **alist, void *data_ref, int (*cmp)(), void (*del)(void *, size_t));
|
||||
void ft_lst_delsub(t_list **alst, t_list *sub, int (*cmp)(), void (*del)(void *, size_t));
|
||||
void ft_lst_cfree(void *ptr, size_t size);
|
||||
t_list *ft_lst_filter(t_list *lst, void const *data_ref, t_list *(*f)(t_list *elem, void const *));
|
||||
|
||||
int ft_diff(void *a, void *b);
|
||||
void *ft_id(void *a);
|
||||
t_list *ft_id(t_list *a);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue