From 1925805cc760061d5742f9d215998561fcd45211 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 1 Apr 2020 23:02:59 +0200 Subject: Added ft_vecremove, Updated README.md --- include/libft_vec.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libft_vec.h b/include/libft_vec.h index 62ec257..f9199ba 100644 --- a/include/libft_vec.h +++ b/include/libft_vec.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 18:57:16 by charles #+# #+# */ -/* Updated: 2020/04/01 19:40:53 by charles ### ########.fr */ +/* Updated: 2020/04/01 22:53:33 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -42,5 +42,6 @@ t_ftvec *ft_vecgrow(t_ftvec *vec); t_ftvec *ft_vecpush(t_ftvec *vec, void *pushed); void ft_vecpop(t_ftvec *vec, void (*del)(void *elem)); void ft_veciter(t_ftvec *vec, void (*f)(void *elem)); +void ft_vecremove(t_ftvec *vec, size_t i, void (*del)(void *elem)); #endif -- cgit From a2452f88fffffe4e2a278578de5ac961858a5b72 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 2 Apr 2020 11:20:44 +0200 Subject: Fixed ft_vecgrow, Added ft_vecinsert --- include/libft_vec.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libft_vec.h b/include/libft_vec.h index f9199ba..c4e3e22 100644 --- a/include/libft_vec.h +++ b/include/libft_vec.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 18:57:16 by charles #+# #+# */ -/* Updated: 2020/04/01 22:53:33 by charles ### ########.fr */ +/* Updated: 2020/04/02 11:00:57 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,5 +43,6 @@ t_ftvec *ft_vecpush(t_ftvec *vec, void *pushed); void ft_vecpop(t_ftvec *vec, void (*del)(void *elem)); void ft_veciter(t_ftvec *vec, void (*f)(void *elem)); void ft_vecremove(t_ftvec *vec, size_t i, void (*del)(void *elem)); +t_ftvec *ft_vecinsert(t_ftvec *vec, size_t i, void *elem); #endif -- cgit From 948c0953527fe3bef28904b38a16a9e4342e7e98 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Apr 2020 00:29:26 +0200 Subject: Added ft_fnmatch function --- include/libft_str.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libft_str.h b/include/libft_str.h index ea6115d..1b0703f 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:09:56 by cacharle ### ########.fr */ +/* Updated: 2020/04/02 23:45:42 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ # define LIBFT_STR_H # include +# include # include "libft_ctype.h" typedef enum @@ -74,6 +75,12 @@ int ft_strnequ(char const *s1, char const *s2, size_t n); char *ft_strtolower(char *s); char *ft_strtoupper(char *s); +/* +** glob +*/ + +bool ft_fnmatch(const char *pattern, const char *string); + /* ** bloat ? */ -- cgit From d2feec1f97e9f8f201e56ad33662bb663c328a0a Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Apr 2020 07:19:25 +0200 Subject: Changing hash table del function to regular one with a first order internal function, removing a few typedef to instead use standard types --- include/libft.h | 14 +++++++------- include/libft_algo.h | 11 ++++------- include/libft_def.h | 36 ++++++++++++++++++++++++++++++++++++ include/libft_ht.h | 50 ++++++++++++++++++++++++-------------------------- include/libft_lst.h | 2 +- include/libft_mem.h | 2 +- include/libft_types.h | 30 ------------------------------ 7 files changed, 73 insertions(+), 72 deletions(-) create mode 100644 include/libft_def.h delete mode 100644 include/libft_types.h (limited to 'include') diff --git a/include/libft.h b/include/libft.h index 74f074b..e982608 100644 --- a/include/libft.h +++ b/include/libft.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/07 09:45:02 by cacharle #+# #+# */ -/* Updated: 2020/02/10 02:19:47 by cacharle ### ########.fr */ +/* Updated: 2020/04/03 06:32:37 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,18 +17,18 @@ # include # include # include +# include # include # include -# include "libft_types.h" -# include "libft_ctype.h" -# include "libft_io.h" -# include "libft_mem.h" -# include "libft_str.h" - # ifdef __linux__ # include # define OPEN_MAX FOPEN_MAX # endif +# include "libft_io.h" +# include "libft_mem.h" +# include "libft_str.h" +# include "libft_ctype.h" + #endif diff --git a/include/libft_algo.h b/include/libft_algo.h index 7223e7b..04191e6 100644 --- a/include/libft_algo.h +++ b/include/libft_algo.h @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ft_algo.h :+: :+: :+: */ +/* libft_algo.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/19 07:22:57 by cacharle #+# #+# */ -/* Updated: 2020/02/10 05:58:26 by cacharle ### ########.fr */ +/* Updated: 2020/04/03 07:05:04 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,11 +14,8 @@ # define LIBFT_ALGO_H # include -# include # include "libft_mem.h" -# include "libft_types.h" - -typedef int (*t_ftcompar_func)(const void*, const void*); +# include "libft_def.h" typedef struct { @@ -39,7 +36,7 @@ typedef struct s_ft_search_const t_ftcompar_func compar; } t_ftsearch_const; -t_ftbool ft_is_set(void *base, size_t nel, size_t width, +bool ft_is_set(void *base, size_t nel, size_t width, t_ftcompar_func compar); int ft_compar_int(const void *a, const void *b); void ft_qsort(void *base, size_t nel, size_t width, diff --git a/include/libft_def.h b/include/libft_def.h new file mode 100644 index 0000000..69a7655 --- /dev/null +++ b/include/libft_def.h @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_def.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/31 10:36:56 by cacharle #+# #+# */ +/* Updated: 2020/04/03 07:04:57 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_DEF_H +# define LIBFT_DEF_H + +# include +# include + +# define TRUE 1 +# define FALSE 0 + +typedef unsigned char t_ftbyte; +typedef int t_ftbool; +typedef unsigned int t_ftsize; + +typedef char t_ftchar; +typedef unsigned char t_ftuchar; +typedef int t_ftint; +typedef unsigned int t_ftuint; +typedef long int t_ftlong; +typedef unsigned long int t_ftulong; + +typedef void (*t_ftdel_func)(void*); +typedef int (*t_ftcompar_func)(const void*, const void*); + +#endif diff --git a/include/libft_ht.h b/include/libft_ht.h index 10c6fc7..b3c1d2d 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:09 by cacharle #+# #+# */ -/* Updated: 2020/04/01 17:59:35 by charles ### ########.fr */ +/* Updated: 2020/04/03 07:12:12 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ */ # include "libft.h" +# include "libft_def.h" # include "libft_lst.h" /* @@ -27,45 +28,42 @@ ** \param value Pointer to data */ -typedef struct s_ftht_entry +typedef struct s_ftht_entry { - char *key; - void *value; -} t_ftht_entry; - -typedef t_ftlst* t_ftht_bucket; + char *key; + void *value; +} t_ftht_entry; /* ** \brief Hash table struct ** \param size Number of buckets -** \param buckets Bucket array +** \param buckets Bucket array, each bucket is a linked list */ -typedef struct s_ftht +typedef struct s_ftht { - t_ftsize size; - t_ftht_bucket *buckets; -} t_ftht; - -typedef t_ftuint t_ftht_digest; + size_t size; + t_ftlst **buckets; +} t_ftht; -t_ftht_digest ft_hthash(t_ftht *ht, char *key); +size_t ft_hthash(t_ftht *ht, char *key); -t_ftht *ft_htnew(t_ftsize size); -void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_entry*)); -void *ft_htget(t_ftht *ht, char *key); -t_ftht_entry *ft_htset(t_ftht *ht, char *key, void *value, - void (*del)(t_ftht_entry*)); -void ft_htdelone(t_ftht *ht, char *key, - void (*del)(t_ftht_entry*)); -t_ftht_entry *ft_htentry_new(char *key, void *value); -void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*)); +t_ftht *ft_htnew(size_t size); +void ft_htdestroy(t_ftht *ht, t_ftdel_func del); +void *ft_htget(t_ftht *ht, char *key); +t_ftht_entry *ft_htset(t_ftht *ht, char *key, void *value, + t_ftdel_func del); +void ft_htdelone(t_ftht *ht, char *key, t_ftdel_func del); +t_ftht_entry *ft_htentry_new(char *key, void *value); +void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*)); /* ** internals */ -int ft_inter_htkey_cmp(const void *ref_key, - const void *content); +int ft_inter_htkey_cmp(const void *ref_key, const void *content); +void ft_inter_htdel_first_order(t_ftht_entry *entry); +void ft_inter_htdel_first_order_setup(t_ftdel_func del); +void ft_inter_htdel_first_order_teardown(void); #endif diff --git a/include/libft_lst.h b/include/libft_lst.h index d7157a9..2938bd2 100644 --- a/include/libft_lst.h +++ b/include/libft_lst.h @@ -19,7 +19,7 @@ */ # include -# include "libft_types.h" +# include "libft_def.h" # include "libft_algo.h" /* diff --git a/include/libft_mem.h b/include/libft_mem.h index 37c072e..26b4ccd 100644 --- a/include/libft_mem.h +++ b/include/libft_mem.h @@ -14,7 +14,7 @@ # define LIBFT_MEM_H # include -# include "libft_types.h" +# include "libft_def.h" void ft_bzero(void *s, size_t n); void *ft_memset(void *s, int c, size_t n); diff --git a/include/libft_types.h b/include/libft_types.h deleted file mode 100644 index 3987a80..0000000 --- a/include/libft_types.h +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* libft_types.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/01/31 10:36:56 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:10:02 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef LIBFT_TYPES_H -# define LIBFT_TYPES_H - -# define TRUE 1 -# define FALSE 0 - -typedef unsigned char t_ftbyte; -typedef int t_ftbool; -typedef unsigned int t_ftsize; - -typedef char t_ftchar; -typedef unsigned char t_ftuchar; -typedef int t_ftint; -typedef unsigned int t_ftuint; -typedef long int t_ftlong; -typedef unsigned long int t_ftulong; - -#endif -- cgit From bf263810b0a47a68fae0681e6e6d2229a488c069 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Apr 2020 15:11:33 +0200 Subject: Added Dynamic string struct (no test, no doc) --- include/libft_dstr.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 include/libft_dstr.h (limited to 'include') diff --git a/include/libft_dstr.h b/include/libft_dstr.h new file mode 100644 index 0000000..13cb4e3 --- /dev/null +++ b/include/libft_dstr.h @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_dstr.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/03 10:39:51 by charles #+# #+# */ +/* Updated: 2020/04/03 15:10:54 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_DSTR_H +# define LIBFT_DSTR_H + +# include +# include "libft_def.h" +# include "libft_str.h" +# include "libft_mem.h" + +typedef struct s_ftdstr +{ + char *str; + size_t length; + size_t capacity; +} t_ftdstr; + +t_ftdstr *ft_dstrnew(char *from); +void ft_dstrdestroy(t_ftdstr *dstr); +t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); +char *ft_dstrunwrap(t_ftdstr *dstr); +t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); +// t_ftdstr *ft_dstrreplace(t_ftdstr *dstr, char *from, char *to); + +#endif -- cgit From 636c3ff6b600c291a40877ac52d8b0a1a58b9b79 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 3 Apr 2020 17:06:38 +0200 Subject: Added doubly linked list struct and basic functions on it --- include/libft_dlst.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 include/libft_dlst.h (limited to 'include') diff --git a/include/libft_dlst.h b/include/libft_dlst.h new file mode 100644 index 0000000..9870ea7 --- /dev/null +++ b/include/libft_dlst.h @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft_dlst.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/03 15:15:04 by charles #+# #+# */ +/* Updated: 2020/04/03 15:44:32 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef LIBFT_DLST_H +# define LIBFT_DLST_H + +# include +# include "libft_def.h" + +typedef struct s_ftdlst +{ + struct s_ftdlst *prev; + struct s_ftdlst *next; + void *data; +} t_ftdlst; + +t_ftdlst *ft_dlstnew(void *data); +void ft_dlstdestroy(t_ftdlst *dlst, t_ftdel_func del); +void ft_dlstdelone(t_ftdlst *dlst, t_ftdel_func del); + +#endif -- cgit From 51b845a6a202b50966f50e166cfb11bcbdccbe33 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 4 Apr 2020 15:58:24 +0200 Subject: Added ft_strsjoin, ft_strsjoinf, ft_compar_str, ft_vecsort, ft_vecpush_safe --- include/libft_algo.h | 4 +++- include/libft_str.h | 10 +++++++++- include/libft_vec.h | 7 +++++-- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/libft_algo.h b/include/libft_algo.h index 04191e6..e726d1f 100644 --- a/include/libft_algo.h +++ b/include/libft_algo.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/19 07:22:57 by cacharle #+# #+# */ -/* Updated: 2020/04/03 07:05:04 by charles ### ########.fr */ +/* Updated: 2020/04/04 15:46:10 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ # include # include "libft_mem.h" # include "libft_def.h" +# include "libft_str.h" typedef struct { @@ -39,6 +40,7 @@ typedef struct s_ft_search_const bool ft_is_set(void *base, size_t nel, size_t width, t_ftcompar_func compar); int ft_compar_int(const void *a, const void *b); +int ft_compar_str(const void *s1_p, const void *s2_p); void ft_qsort(void *base, size_t nel, size_t width, t_ftcompar_func compar); int ft_mergesort(void *base, size_t nel, size_t width, diff --git a/include/libft_str.h b/include/libft_str.h index 1b0703f..2b105bf 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/04/02 23:45:42 by charles ### ########.fr */ +/* Updated: 2020/04/04 14:41:46 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ # include # include # include "libft_ctype.h" +# include "libft_util.h" typedef enum { @@ -81,6 +82,13 @@ char *ft_strtoupper(char *s); bool ft_fnmatch(const char *pattern, const char *string); +/* +** NULL terminated string array +*/ + +char *ft_strsjoin(char **strs, char *delim); +char *ft_strsjoinf(char **strs, char *delim); + /* ** bloat ? */ diff --git a/include/libft_vec.h b/include/libft_vec.h index c4e3e22..8424bd5 100644 --- a/include/libft_vec.h +++ b/include/libft_vec.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 18:57:16 by charles #+# #+# */ -/* Updated: 2020/04/02 11:00:57 by charles ### ########.fr */ +/* Updated: 2020/04/04 15:55:29 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,8 +19,9 @@ */ # include -# include +# include "libft_def.h" # include "libft_mem.h" +# include "libft_algo.h" /* ** \brief Vector struct @@ -40,9 +41,11 @@ t_ftvec *ft_vecnew(size_t capacity); void ft_vecdestroy(t_ftvec *vec, void (*del)(void *elem)); t_ftvec *ft_vecgrow(t_ftvec *vec); t_ftvec *ft_vecpush(t_ftvec *vec, void *pushed); +t_ftvec *ft_vecpush_safe(t_ftvec *vec, void *pushed); void ft_vecpop(t_ftvec *vec, void (*del)(void *elem)); void ft_veciter(t_ftvec *vec, void (*f)(void *elem)); void ft_vecremove(t_ftvec *vec, size_t i, void (*del)(void *elem)); t_ftvec *ft_vecinsert(t_ftvec *vec, size_t i, void *elem); +void ft_vecsort(t_ftvec *vec, t_ftcompar_func cmp); #endif -- cgit From 42316d8393d32bd88fb8e0cba6825185f78dacd0 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 4 Apr 2020 21:28:21 +0200 Subject: Added test and doc for dynamic string --- include/libft_dstr.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libft_dstr.h b/include/libft_dstr.h index 13cb4e3..11bf2f4 100644 --- a/include/libft_dstr.h +++ b/include/libft_dstr.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 10:39:51 by charles #+# #+# */ -/* Updated: 2020/04/03 15:10:54 by charles ### ########.fr */ +/* Updated: 2020/04/04 21:18:48 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,13 @@ # include "libft_str.h" # include "libft_mem.h" +/* +** \brief Dynamic string struct +** \param str Underlying null-terminated character array +** \param length Number of character (not including the '\0') +** \param capacity Maximum length - 1 of the current string +*/ + typedef struct s_ftdstr { char *str; @@ -30,6 +37,6 @@ void ft_dstrdestroy(t_ftdstr *dstr); t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); char *ft_dstrunwrap(t_ftdstr *dstr); t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); -// t_ftdstr *ft_dstrreplace(t_ftdstr *dstr, char *from, char *to); +// t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, size_t start, size_t end); #endif -- cgit From 65cf641e9533b190db870d0cc46f2f852239ebf6 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 4 Apr 2020 23:36:19 +0200 Subject: Added test for ft_strsjoin, ft_strsjoinf, ft_vecpush_safe, Added doc for algo functions, tested functions --- include/libft_algo.h | 25 ++++++++++++++++++++++++- include/libft_def.h | 26 +++++++++++++++++++++++--- include/libft_dstr.h | 5 +++-- include/libft_ht.h | 3 ++- 4 files changed, 52 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/libft_algo.h b/include/libft_algo.h index e726d1f..e859de5 100644 --- a/include/libft_algo.h +++ b/include/libft_algo.h @@ -6,10 +6,15 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/19 07:22:57 by cacharle #+# #+# */ -/* Updated: 2020/04/04 15:46:10 by charles ### ########.fr */ +/* Updated: 2020/04/04 23:33:51 by charles ### ########.fr */ /* */ /* ************************************************************************** */ +/* +** \file libft_algo.h +** \brief Algorithms +*/ + #ifndef LIBFT_ALGO_H # define LIBFT_ALGO_H @@ -18,12 +23,26 @@ # include "libft_def.h" # include "libft_str.h" +/* +** \brief Range struct +** \param lo Lower bound +** \param hi Upper bound +*/ + typedef struct { int lo; int hi; } t_ftrange; +/* +** \brief Merge sort consts struct +** \param base Array to sort +** \param left Left subarray +** \param right Right subarray +** \note Only used internaly by ft_mergesort +*/ + struct s_merge_sorted_arrays { void *base; @@ -31,6 +50,10 @@ struct s_merge_sorted_arrays void *right; }; +/* +** remove this horror +*/ + typedef struct s_ft_search_const { const void *key; diff --git a/include/libft_def.h b/include/libft_def.h index 69a7655..7406959 100644 --- a/include/libft_def.h +++ b/include/libft_def.h @@ -6,10 +6,15 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:56 by cacharle #+# #+# */ -/* Updated: 2020/04/03 07:04:57 by charles ### ########.fr */ +/* Updated: 2020/04/04 21:40:37 by charles ### ########.fr */ /* */ /* ************************************************************************** */ +/* +** \file libft_def.h +** \brief Type and constant definition +*/ + #ifndef LIBFT_DEF_H # define LIBFT_DEF_H @@ -30,7 +35,22 @@ typedef unsigned int t_ftuint; typedef long int t_ftlong; typedef unsigned long int t_ftulong; -typedef void (*t_ftdel_func)(void*); -typedef int (*t_ftcompar_func)(const void*, const void*); +/* +** \brief Standard delete function +** \param x Resource to delete +*/ + +typedef void (*t_ftdel_func)(void *x); + +/* +** \brief Standard comparison function +** \param x1 Resource 1 +** \param x2 Resource 2 +** \return negative number if x1 < x2, +** 0 if x1 == x2, +** positive number if x1 > x2 +*/ + +typedef int (*t_ftcompar_func)(const void *x1, const void *x2); #endif diff --git a/include/libft_dstr.h b/include/libft_dstr.h index 11bf2f4..fbe69db 100644 --- a/include/libft_dstr.h +++ b/include/libft_dstr.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 10:39:51 by charles #+# #+# */ -/* Updated: 2020/04/04 21:18:48 by charles ### ########.fr */ +/* Updated: 2020/04/04 23:33:27 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,6 +37,7 @@ void ft_dstrdestroy(t_ftdstr *dstr); t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); char *ft_dstrunwrap(t_ftdstr *dstr); t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); -// t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, size_t start, size_t end); +t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, + size_t start, size_t end); #endif diff --git a/include/libft_ht.h b/include/libft_ht.h index b3c1d2d..c53ee4d 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:09 by cacharle #+# #+# */ -/* Updated: 2020/04/03 07:12:12 by charles ### ########.fr */ +/* Updated: 2020/04/04 22:34:53 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,7 @@ # include "libft.h" # include "libft_def.h" # include "libft_lst.h" +# include "libft_mem.h" /* ** \brief Hash table entry, key/value pair -- cgit From 944a236443bacf531085b346d06907b24e3739b1 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 5 Apr 2020 01:11:50 +0200 Subject: Added ft_dstrerase, ft_dstrsubstitute --- include/libft_dstr.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libft_dstr.h b/include/libft_dstr.h index fbe69db..732e475 100644 --- a/include/libft_dstr.h +++ b/include/libft_dstr.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 10:39:51 by charles #+# #+# */ -/* Updated: 2020/04/04 23:33:27 by charles ### ########.fr */ +/* Updated: 2020/04/05 00:37:05 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,7 +37,8 @@ void ft_dstrdestroy(t_ftdstr *dstr); t_ftdstr *ft_dstrgrow(t_ftdstr *dstr, size_t at_least); char *ft_dstrunwrap(t_ftdstr *dstr); t_ftdstr *ft_dstrinsert(t_ftdstr *dstr, char *inserted, size_t i); -t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *sub, +void ft_dstrerase(t_ftdstr *dstr, size_t start, size_t len); +t_ftdstr *ft_dstrsubstitute(t_ftdstr *dstr, char *replacement, size_t start, size_t end); #endif -- cgit From 3a2d19df9e509d0b015c786eb02f8315ff0ad91c Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 5 Apr 2020 14:05:43 +0200 Subject: Renamed ft_substr to ft_strsub, Added ft_strsubf, ft_strcat3 --- include/libft_str.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libft_str.h b/include/libft_str.h index 2b105bf..195e750 100644 --- a/include/libft_str.h +++ b/include/libft_str.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */ -/* Updated: 2020/04/04 14:41:46 by charles ### ########.fr */ +/* Updated: 2020/04/05 13:52:10 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -52,7 +52,8 @@ int ft_atoi(const char *nptr); void ft_striter(char *s, void (*f)(char *)); void ft_striteri(char *s, void (*f)(unsigned int, char *)); -char *ft_substr(char const *s, unsigned int start, size_t len); +char *ft_strsub(char const *s, size_t start, size_t len); +char *ft_strsubf(char const *s, size_t start, size_t len); char *ft_strjoin(char const *s1, char const *s2); char *ft_strjoin3(char const *s1, char const *s2, char const *s3); char *ft_strjoinf(char const *s1, char const *s2, t_ftstrjoinf_tag tag); @@ -75,6 +76,7 @@ int ft_strequ(char const *s1, char const *s2); int ft_strnequ(char const *s1, char const *s2, size_t n); char *ft_strtolower(char *s); char *ft_strtoupper(char *s); +char *ft_strcat3(char *dest, const char *src1, const char *src2); /* ** glob -- cgit