aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.libftignore1
-rw-r--r--Makefile2
-rw-r--r--include/libft_ht.h11
-rw-r--r--include/libft_io.h11
-rw-r--r--include/libft_lst.h49
-rw-r--r--include/libft_mem.h11
-rw-r--r--include/libft_printf.h11
-rw-r--r--include/libft_str.h11
-rw-r--r--include/libft_types.h11
-rw-r--r--src/lst/ft_lstadd_back.c3
-rw-r--r--src/lst/ft_lstadd_front.c3
-rw-r--r--src/lst/ft_lstbsearch.c25
-rw-r--r--src/lst/ft_lstclear.c3
-rw-r--r--src/lst/ft_lstdelone.c3
-rw-r--r--src/lst/ft_lstiter.c3
-rw-r--r--src/lst/ft_lstlast.c3
-rw-r--r--src/lst/ft_lstmap.c9
-rw-r--r--src/lst/ft_lstnew.c7
-rw-r--r--src/lst/ft_lstpop_front.c6
-rw-r--r--src/lst/ft_lstremove_if.c9
-rw-r--r--src/lst/ft_lstreverse.c3
-rw-r--r--src/lst/ft_lstreverse_ret.c5
-rw-r--r--src/lst/ft_lstsize.c3
23 files changed, 70 insertions, 133 deletions
diff --git a/.libftignore b/.libftignore
index dfb5df9..7ec6e32 100644
--- a/.libftignore
+++ b/.libftignore
@@ -1,3 +1,2 @@
*ft_printf*
*ft_ht*
-*ft_lst*
diff --git a/Makefile b/Makefile
index 27ac82e..9127ccb 100644
--- a/Makefile
+++ b/Makefile
@@ -48,7 +48,7 @@ $(NAME): $(OBJ) $(HEADER)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "Compiling: $@"
- @$(CC) $(CCFLAGS) -c -o $@ $<
+ $(CC) $(CCFLAGS) -c -o $@ $<
clean:
@echo "Removing objects"
diff --git a/include/libft_ht.h b/include/libft_ht.h
index bd67b47..b890316 100644
--- a/include/libft_ht.h
+++ b/include/libft_ht.h
@@ -1,14 +1,3 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* ft_ht.h :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2020/01/30 08:19:23 by cacharle #+# #+# */
-/* Updated: 2020/01/30 10:34:40 by cacharle ### ########.fr */
-/* */
-/* ************************************************************************** */
#ifndef FT_HT
# define FT_HT
diff --git a/include/libft_io.h b/include/libft_io.h
index f4c223b..75dda57 100644
--- a/include/libft_io.h
+++ b/include/libft_io.h
@@ -1,14 +1,3 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* ft_io.h :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2020/01/17 09:47:14 by cacharle #+# #+# */
-/* Updated: 2020/01/17 10:07:47 by cacharle ### ########.fr */
-/* */
-/* ************************************************************************** */
#ifndef FT_IO_H
# define FT_IO_H
diff --git a/include/libft_lst.h b/include/libft_lst.h
index 23fb192..8f77233 100644
--- a/include/libft_lst.h
+++ b/include/libft_lst.h
@@ -1,38 +1,29 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* ft_lst.h :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2020/01/17 09:58:02 by cacharle #+# #+# */
-/* Updated: 2020/01/30 09:55:43 by cacharle ### ########.fr */
-/* */
-/* ************************************************************************** */
-#ifndef FT_LST_H
-# define FT_LST_H
+#ifndef LIBFT_LST_H
+# define LIBFT_LST_H
-typedef struct s_list
+# include "libft_types.h"
+
+typedef struct s_ftlst
{
void *content;
- struct s_list *next;
-} t_list;
+ struct s_ftlst *next;
+} t_ftlst;
-t_list *ft_lstnew(void const *content);
-void ft_lstadd_front(t_list **alst, t_list *new);
-int ft_lstsize(t_list *lst);
-t_list *ft_lstlast(t_list *lst);
-void ft_lstadd_back(t_list **alst, t_list *new);
-void ft_lstdelone(t_list *lst, void (*del)(void *));
-void ft_lstclear(t_list **lst, void (*del)(void *));
-void ft_lstiter(t_list *lst, void (*f)(void *));
-t_list *ft_lstmap(t_list *lst, void *(*f)(void *),
+t_ftlst *ft_lstnew(void const *content);
+void ft_lstadd_front(t_ftlst **alst, t_ftlst *new);
+int ft_lstsize(t_ftlst *lst);
+t_ftlst *ft_lstlast(t_ftlst *lst);
+void ft_lstadd_back(t_ftlst **alst, t_ftlst *new);
+void ft_lstdelone(t_ftlst *lst, void (*del)(void *));
+void ft_lstclear(t_ftlst **lst, void (*del)(void *));
+void ft_lstiter(t_ftlst *lst, void (*f)(void *));
+t_ftlst *ft_lstmap(t_ftlst *lst, void *(*f)(void *),
void (*del)(void *));
-void ft_lstpop_front(t_list **lst, void (*del)(void *));
-t_list *ft_lstreverse_ret(t_list *lst);
-void ft_lstreverse(t_list **lst);
-void ft_lstremove_if(t_list **lst,
+void ft_lstpop_front(t_ftlst **lst, void (*del)(void *));
+t_ftlst *ft_lstreverse_ret(t_ftlst *lst);
+void ft_lstreverse(t_ftlst **lst);
+void ft_lstremove_if(t_ftlst **lst,
t_ftbool (*equal)(void *ref, void *content), void *ref,
void (*del)(void *content));
diff --git a/include/libft_mem.h b/include/libft_mem.h
index d1e47f6..a9717b8 100644
--- a/include/libft_mem.h
+++ b/include/libft_mem.h
@@ -1,14 +1,3 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* ft_mem.h :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2020/01/17 09:56:20 by cacharle #+# #+# */
-/* Updated: 2020/01/17 09:57:54 by cacharle ### ########.fr */
-/* */
-/* ************************************************************************** */
#ifndef FT_MEM_H
# define FT_MEM_H
diff --git a/include/libft_printf.h b/include/libft_printf.h
index 615039b..1200478 100644
--- a/include/libft_printf.h
+++ b/include/libft_printf.h
@@ -1,14 +1,3 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* ft_printf.h :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2020/01/17 10:05:59 by cacharle #+# #+# */
-/* Updated: 2020/01/17 10:10:18 by cacharle ### ########.fr */
-/* */
-/* ************************************************************************** */
#ifndef FT_PRINTF_H
# define FT_PRINTF_H
diff --git a/include/libft_str.h b/include/libft_str.h
index 105da79..8c4bef5 100644
--- a/include/libft_str.h
+++ b/include/libft_str.h
@@ -1,14 +1,3 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* ft_str.h :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2020/01/17 09:50:14 by cacharle #+# #+# */
-/* Updated: 2020/01/17 10:22:38 by cacharle ### ########.fr */
-/* */
-/* ************************************************************************** */
#ifndef FT_STR_H
# define FT_STR_H
diff --git a/include/libft_types.h b/include/libft_types.h
index 04c9f02..be1cc20 100644
--- a/include/libft_types.h
+++ b/include/libft_types.h
@@ -1,14 +1,3 @@
-/* ************************************************************************** */
-/* */
-/* ::: :::::::: */
-/* ft_types.h :+: :+: :+: */
-/* +:+ +:+ +:+ */
-/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
-/* +#+#+#+#+#+ +#+ */
-/* Created: 2020/01/17 09:59:15 by cacharle #+# #+# */
-/* Updated: 2020/01/30 09:54:28 by cacharle ### ########.fr */
-/* */
-/* ************************************************************************** */
#ifndef FT_TYPES_H
# define FT_TYPES_H
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;