From 8131a5d26441c5152ab151b4bb49b561e5ca6e81 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 31 Jan 2020 10:44:30 +0100 Subject: hash table unit testing, norming --- include/libft_ht.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/libft_ht.h') diff --git a/include/libft_ht.h b/include/libft_ht.h index 62f2ee1..5a764b6 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/02/19 02:38:28 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:18:19 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ -- cgit From e792d0a3ff1c1da456c241530571263df0b887b5 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 4 Mar 2020 16:19:05 +0100 Subject: Added ft_htiter.c --- include/libft_ht.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/libft_ht.h') diff --git a/include/libft_ht.h b/include/libft_ht.h index 5a764b6..ea6cb3f 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -45,6 +45,7 @@ void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_content*)); void ft_htdelone_key(t_ftht *ht, char *key); t_ftht_content *ft_htcontent_new(char *key, void *value); +void ft_htiter(t_ftht *ht, void (*f)(t_ftht_content*)); /* ** internals -- cgit From 901402c99018422c994bdb297e3ba404969c88ea Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 30 Mar 2020 22:26:36 +0200 Subject: Added documentation for ht and lst --- include/libft_ht.h | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'include/libft_ht.h') diff --git a/include/libft_ht.h b/include/libft_ht.h index ea6cb3f..24abf95 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -13,21 +13,38 @@ #ifndef LIBFT_HT_H # define LIBFT_HT_H +/** +** \file libft_ht.h +** \brief Hash table manipulation +*/ + # include "libft.h" # include "libft_lst.h" -typedef struct s_ftht_content +/** +** \brief Hash table entry, key/value pair +** \param key String key +** \param value Pointer to data +*/ + +typedef struct s_ftht_entry { char *key; void *value; -} t_ftht_content; +} t_ftht_entry; + +typedef t_ftlst* t_ftht_bucket; -typedef t_ftlst* t_ftht_entry; +/** +** \brief Hash table struct +** \param size Number of buckets +** \param buckets Bucket array +*/ typedef struct s_ftht { t_ftsize size; - t_ftht_entry *entries; + t_ftht_bucket *buckets; } t_ftht; typedef t_ftuint t_ftht_digest; @@ -35,23 +52,19 @@ typedef t_ftuint t_ftht_digest; t_ftht_digest ft_hthash(t_ftht *ht, char *key); t_ftht *ft_htnew(t_ftsize size); -void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_content*)); -void ft_htdestroy_all(t_ftht *ht); -void ft_htdestroy_key(t_ftht *ht); +void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_entry*)); void *ft_htget(t_ftht *ht, char *key); -t_ftht_content *ft_htset(t_ftht *ht, char *key, void *value, - void (*del)(t_ftht_content*)); +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_content*)); -void ft_htdelone_key(t_ftht *ht, char *key); -t_ftht_content *ft_htcontent_new(char *key, void *value); -void ft_htiter(t_ftht *ht, void (*f)(t_ftht_content*)); + 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*)); /* ** internals */ -void ft_inter_htdelcontent_key(t_ftht_content *content); int ft_inter_htkey_cmp(const void *ref_key, const void *content); -- cgit From 9316f2063255bd4a0abd5c38d4c065969a8980bb Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 1 Apr 2020 18:10:36 +0200 Subject: Norm compliant comment format, dirty script for doxygen comments --- include/libft_ht.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/libft_ht.h') diff --git a/include/libft_ht.h b/include/libft_ht.h index 24abf95..10c6fc7 100644 --- a/include/libft_ht.h +++ b/include/libft_ht.h @@ -6,14 +6,14 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/31 10:36:09 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:18:19 by cacharle ### ########.fr */ +/* Updated: 2020/04/01 17:59:35 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef LIBFT_HT_H # define LIBFT_HT_H -/** +/* ** \file libft_ht.h ** \brief Hash table manipulation */ @@ -21,7 +21,7 @@ # include "libft.h" # include "libft_lst.h" -/** +/* ** \brief Hash table entry, key/value pair ** \param key String key ** \param value Pointer to data @@ -35,7 +35,7 @@ typedef struct s_ftht_entry typedef t_ftlst* t_ftht_bucket; -/** +/* ** \brief Hash table struct ** \param size Number of buckets ** \param buckets Bucket array @@ -59,7 +59,7 @@ t_ftht_entry *ft_htset(t_ftht *ht, char *key, void *value, 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*)); +void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*)); /* ** internals -- 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_ht.h | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'include/libft_ht.h') 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 -- 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_ht.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/libft_ht.h') 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