diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-30 20:24:32 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-30 20:24:32 +0100 |
| commit | 6500b1ca9ce911d3db7c94ee3f4ee38489b8861a (patch) | |
| tree | 4d2766b1bea4322a6e5851f53af33178d9643a5c /src | |
| parent | aa244ec3fb071a7fd08494d04cc865b281502804 (diff) | |
| download | libft-6500b1ca9ce911d3db7c94ee3f4ee38489b8861a.tar.gz libft-6500b1ca9ce911d3db7c94ee3f4ee38489b8861a.tar.bz2 libft-6500b1ca9ce911d3db7c94ee3f4ee38489b8861a.zip | |
Renaming t_list -> t_ftlst, changing feature adding by header
Diffstat (limited to 'src')
| -rw-r--r-- | src/lst/ft_lstadd_back.c | 3 | ||||
| -rw-r--r-- | src/lst/ft_lstadd_front.c | 3 | ||||
| -rw-r--r-- | src/lst/ft_lstbsearch.c | 25 | ||||
| -rw-r--r-- | src/lst/ft_lstclear.c | 3 | ||||
| -rw-r--r-- | src/lst/ft_lstdelone.c | 3 | ||||
| -rw-r--r-- | src/lst/ft_lstiter.c | 3 | ||||
| -rw-r--r-- | src/lst/ft_lstlast.c | 3 | ||||
| -rw-r--r-- | src/lst/ft_lstmap.c | 9 | ||||
| -rw-r--r-- | src/lst/ft_lstnew.c | 7 | ||||
| -rw-r--r-- | src/lst/ft_lstpop_front.c | 6 | ||||
| -rw-r--r-- | src/lst/ft_lstremove_if.c | 9 | ||||
| -rw-r--r-- | src/lst/ft_lstreverse.c | 3 | ||||
| -rw-r--r-- | src/lst/ft_lstreverse_ret.c | 5 | ||||
| -rw-r--r-- | src/lst/ft_lstsize.c | 3 |
14 files changed, 49 insertions, 36 deletions
diff --git a/src/lst/ft_lstadd_back.c b/src/lst/ft_lstadd_back.c index 01eb00c..8f39a75 100644 --- a/src/lst/ft_lstadd_back.c +++ b/src/lst/ft_lstadd_back.c @@ -11,8 +11,9 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -void ft_lstadd_back(t_list **alst, t_list *new) +void ft_lstadd_back(t_ftlst **alst, t_ftlst *new) { if (alst == NULL) return ; diff --git a/src/lst/ft_lstadd_front.c b/src/lst/ft_lstadd_front.c index 282b0b4..bcd5ad9 100644 --- a/src/lst/ft_lstadd_front.c +++ b/src/lst/ft_lstadd_front.c @@ -11,8 +11,9 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -void ft_lstadd_front(t_list **alst, t_list *new) +void ft_lstadd_front(t_ftlst **alst, t_ftlst *new) { if (alst == NULL || new == NULL) return ; diff --git a/src/lst/ft_lstbsearch.c b/src/lst/ft_lstbsearch.c index 6af9cae..3d5dbde 100644 --- a/src/lst/ft_lstbsearch.c +++ b/src/lst/ft_lstbsearch.c @@ -11,11 +11,12 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -static t_list *st_lstmiddle(t_list *lst, t_list) +static t_ftlst *st_lstmiddle(t_ftlst *lst, t_ftlst *last) { - t_list *slow; - t_list *fast; + t_ftlst *slow; + t_ftlst *fast; if (lst == NULL) return (NULL); @@ -32,25 +33,25 @@ static t_list *st_lstmiddle(t_list *lst, t_list) return (slow); } -static t_list *st_lstbsearch_rec(t_list *lst, t_list *last, +static t_ftlst *st_lstbsearch_rec(t_ftlst *lst, t_ftlst *last, t_ftbool (*equal)(void *ref, void *content), void *ref) { - t_list *mid; - t_list *left; + t_ftlst *mid; + t_ftlst *left; if (lst == NULL) return (NULL); - if ((*equal)(lst->content)) - return (lst); mid = st_lstmiddle(lst, last); - left = ft_lstbsearch_rec(lst->next, mid, equal)); + if ((*equal)(ref, mid->content)) + return (mid); + left = st_lstbsearch_rec(lst, mid, equal, ref); if (left != NULL) return (left); - return (ft_lstbsearch_rec(mid, NULL, equal)); + return (st_lstbsearch_rec(mid, NULL, equal, ref)); } -t_list *ft_lstbsearch(t_list *lst, +t_ftlst *ft_lstbsearch(t_ftlst *lst, t_ftbool (*equal)(void *ref, void *content), void *ref) { - return (ft_lstbsearch_rec(lst, NULL, equal)); + return (st_lstbsearch_rec(lst, NULL, equal, ref)); } diff --git a/src/lst/ft_lstclear.c b/src/lst/ft_lstclear.c index ee1d9e5..0bacb4f 100644 --- a/src/lst/ft_lstclear.c +++ b/src/lst/ft_lstclear.c @@ -11,8 +11,9 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -void ft_lstclear(t_list **lst, void (*del)(void *)) +void ft_lstclear(t_ftlst **lst, void (*del)(void *)) { if (lst == NULL) return ; diff --git a/src/lst/ft_lstdelone.c b/src/lst/ft_lstdelone.c index 30cec69..63dcc35 100644 --- a/src/lst/ft_lstdelone.c +++ b/src/lst/ft_lstdelone.c @@ -11,8 +11,9 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -void ft_lstdelone(t_list *lst, void (*del)(void *)) +void ft_lstdelone(t_ftlst *lst, void (*del)(void *)) { if (lst == NULL) return ; diff --git a/src/lst/ft_lstiter.c b/src/lst/ft_lstiter.c index 282e0fa..9b2895b 100644 --- a/src/lst/ft_lstiter.c +++ b/src/lst/ft_lstiter.c @@ -11,8 +11,9 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -void ft_lstiter(t_list *lst, void (*f)(void *)) +void ft_lstiter(t_ftlst *lst, void (*f)(void *)) { if (f == NULL) return ; diff --git a/src/lst/ft_lstlast.c b/src/lst/ft_lstlast.c index 247f4da..728cbf2 100644 --- a/src/lst/ft_lstlast.c +++ b/src/lst/ft_lstlast.c @@ -11,8 +11,9 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -t_list *ft_lstlast(t_list *lst) +t_ftlst *ft_lstlast(t_ftlst *lst) { if (lst == NULL) return (NULL); diff --git a/src/lst/ft_lstmap.c b/src/lst/ft_lstmap.c index c623d6f..9039d71 100644 --- a/src/lst/ft_lstmap.c +++ b/src/lst/ft_lstmap.c @@ -11,11 +11,12 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) +t_ftlst *ft_lstmap(t_ftlst *lst, void *(*f)(void *), void (*del)(void *)) { - t_list *mapped; - t_list *tmp; + t_ftlst *mapped; + t_ftlst *tmp; if (lst == NULL || f == NULL) return (NULL); @@ -36,7 +37,7 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) /* ** Rest in peace, my beautiful recursion. ** -** t_list *tmp; +** t_ftlst *tmp; ** ** if (lst == NULL) ** return (NULL); diff --git a/src/lst/ft_lstnew.c b/src/lst/ft_lstnew.c index ea10e4d..11cf223 100644 --- a/src/lst/ft_lstnew.c +++ b/src/lst/ft_lstnew.c @@ -11,12 +11,13 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -t_list *ft_lstnew(void const *content) +t_ftlst *ft_lstnew(void const *content) { - t_list *elem; + t_ftlst *elem; - if ((elem = (t_list*)malloc(sizeof(t_list))) == NULL) + if ((elem = (t_ftlst*)malloc(sizeof(t_ftlst))) == NULL) return (NULL); elem->content = (void*)content; elem->next = NULL; diff --git a/src/lst/ft_lstpop_front.c b/src/lst/ft_lstpop_front.c index f59c9b8..ff386f9 100644 --- a/src/lst/ft_lstpop_front.c +++ b/src/lst/ft_lstpop_front.c @@ -10,12 +10,12 @@ /* */ /* ************************************************************************** */ -#include <stdlib.h> #include "libft.h" +#include "libft_lst.h" -void ft_lstpop_front(t_list **lst, void (*del)(void *)) +void ft_lstpop_front(t_ftlst **lst, void (*del)(void *)) { - t_list *tmp; + t_ftlst *tmp; if (lst == NULL || *lst == NULL) return ; diff --git a/src/lst/ft_lstremove_if.c b/src/lst/ft_lstremove_if.c index 2fa06a3..a597c2e 100644 --- a/src/lst/ft_lstremove_if.c +++ b/src/lst/ft_lstremove_if.c @@ -11,16 +11,17 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -void ft_lstremove_if(t_list **lst, +void ft_lstremove_if(t_ftlst **lst, t_ftbool (*equal)(void *ref, void *content), void *ref, void (*del)(void *content)) { - t_list *saved_next; + t_ftlst *saved_next; if (lst == NULL || *lst == NULL) return ; - if (!equal(ref, &(*lst)->val)) + if (!equal(ref, &(*lst)->content)) { ft_lstremove_if(&(*lst)->next, equal, ref, del); return ; @@ -28,5 +29,5 @@ void ft_lstremove_if(t_list **lst, saved_next = (*lst)->next; ft_lstdelone(*lst, del); *lst = saved_next; - ref_ft_list_remove_if(lst, equal, ref, del); + ft_lstremove_if(lst, equal, ref, del); } diff --git a/src/lst/ft_lstreverse.c b/src/lst/ft_lstreverse.c index c45a912..3d3fc7b 100644 --- a/src/lst/ft_lstreverse.c +++ b/src/lst/ft_lstreverse.c @@ -11,8 +11,9 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -void ft_lstreverse(t_list **lst) +void ft_lstreverse(t_ftlst **lst) { *lst = ft_lstreverse_ret(*lst); } diff --git a/src/lst/ft_lstreverse_ret.c b/src/lst/ft_lstreverse_ret.c index 3e2118f..a3edb99 100644 --- a/src/lst/ft_lstreverse_ret.c +++ b/src/lst/ft_lstreverse_ret.c @@ -11,10 +11,11 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -t_list *ft_lstreverse_ret(t_list *lst) +t_ftlst *ft_lstreverse_ret(t_ftlst *lst) { - t_list *tmp; + t_ftlst *tmp; if (lst == NULL) return (NULL); diff --git a/src/lst/ft_lstsize.c b/src/lst/ft_lstsize.c index b9d65d2..922b581 100644 --- a/src/lst/ft_lstsize.c +++ b/src/lst/ft_lstsize.c @@ -11,8 +11,9 @@ /* ************************************************************************** */ #include "libft.h" +#include "libft_lst.h" -int ft_lstsize(t_list *lst) +int ft_lstsize(t_ftlst *lst) { int counter; |
