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 --- src/ht/ft_htdelone.c | 2 +- src/ht/ft_htdestroy.c | 4 ++-- src/ht/ft_htget.c | 2 +- src/ht/ft_htnew.c | 2 +- src/ht/ft_htset.c | 2 +- src/ht/ft_inter_htkey_cmp.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ht') diff --git a/src/ht/ft_htdelone.c b/src/ht/ft_htdelone.c index 2c54721..77eae58 100644 --- a/src/ht/ft_htdelone.c +++ b/src/ht/ft_htdelone.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 09:27:18 by cacharle #+# #+# */ -/* Updated: 2020/02/19 02:35:06 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:10:16 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/ht/ft_htdestroy.c b/src/ht/ft_htdestroy.c index e0442c6..900f76e 100644 --- a/src/ht/ft_htdestroy.c +++ b/src/ht/ft_htdestroy.c @@ -5,8 +5,8 @@ /* +:+ +:+ +:+ */ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2020/01/30 08:19:06 by cacharle #+# #+# */ -/* Updated: 2020/01/30 08:33:09 by cacharle ### ########.fr */ +/* Created: 2020/01/30 08:31:02 by cacharle #+# #+# */ +/* Updated: 2020/02/28 12:10:31 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/ht/ft_htget.c b/src/ht/ft_htget.c index 76e4fb2..1562eb0 100644 --- a/src/ht/ft_htget.c +++ b/src/ht/ft_htget.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 08:33:21 by cacharle #+# #+# */ -/* Updated: 2020/02/19 01:44:41 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:21:09 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/ht/ft_htnew.c b/src/ht/ft_htnew.c index d98a724..f77398f 100644 --- a/src/ht/ft_htnew.c +++ b/src/ht/ft_htnew.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 08:19:16 by cacharle #+# #+# */ -/* Updated: 2020/02/10 02:16:20 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:10:51 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/ht/ft_htset.c b/src/ht/ft_htset.c index c7068d5..81aba97 100644 --- a/src/ht/ft_htset.c +++ b/src/ht/ft_htset.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 08:41:52 by cacharle #+# #+# */ -/* Updated: 2020/02/19 02:44:10 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:11:00 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/ht/ft_inter_htkey_cmp.c b/src/ht/ft_inter_htkey_cmp.c index 6f04ecc..be2e52f 100644 --- a/src/ht/ft_inter_htkey_cmp.c +++ b/src/ht/ft_inter_htkey_cmp.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 09:24:39 by cacharle #+# #+# */ -/* Updated: 2020/02/19 02:03:14 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:20:43 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ -- cgit From 915f1b888cf9c05e4b61321f84ac045eacd8ddd1 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 27 Feb 2020 18:07:57 +0100 Subject: Added ft_lstlfind,ft_lstlsearch and ft_split_destroy --- src/ht/ft_htnew.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ht') diff --git a/src/ht/ft_htnew.c b/src/ht/ft_htnew.c index f77398f..6827c36 100644 --- a/src/ht/ft_htnew.c +++ b/src/ht/ft_htnew.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 08:19:16 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:10:51 by cacharle ### ########.fr */ +/* Updated: 2020/02/28 12:23:43 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ -- cgit From 2a9133a87109f9430e4827a858ff86596c5f98d5 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 4 Mar 2020 12:49:31 +0100 Subject: Added hash table documentation --- src/ht/ft_htcontent_new.c | 6 ++++++ src/ht/ft_htdelone.c | 4 ++++ src/ht/ft_htdestroy.c | 5 +++++ src/ht/ft_htget.c | 7 ++++++- src/ht/ft_hthash.c | 5 +++++ src/ht/ft_htnew.c | 6 ++++++ src/ht/ft_htset.c | 12 +++++++++--- src/ht/ft_inter_htkey_cmp.c | 4 ++++ 8 files changed, 45 insertions(+), 4 deletions(-) (limited to 'src/ht') diff --git a/src/ht/ft_htcontent_new.c b/src/ht/ft_htcontent_new.c index 214e125..7dd4f20 100644 --- a/src/ht/ft_htcontent_new.c +++ b/src/ht/ft_htcontent_new.c @@ -13,6 +13,12 @@ #include "libft.h" #include "libft_ht.h" +/* +** Create a new hash table key/value pair. +** `key` is always duplicated. +** Return a pointer to the created content or NULL is an allocation failed. +*/ + t_ftht_content *ft_htcontent_new(char *key, void *value) { t_ftht_content *content; diff --git a/src/ht/ft_htdelone.c b/src/ht/ft_htdelone.c index 77eae58..e3bb355 100644 --- a/src/ht/ft_htdelone.c +++ b/src/ht/ft_htdelone.c @@ -13,6 +13,10 @@ #include "libft.h" #include "libft_ht.h" +/* +** Delete one hash table entry at `key`. +*/ + void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_content*)) { ft_lstremove_if(ht->entries + ft_hthash(ht, key), diff --git a/src/ht/ft_htdestroy.c b/src/ht/ft_htdestroy.c index 900f76e..a788a78 100644 --- a/src/ht/ft_htdestroy.c +++ b/src/ht/ft_htdestroy.c @@ -13,6 +13,11 @@ #include "libft.h" #include "libft_ht.h" +/* +** Destroy an hash table. +** The `del` function is used to destroy each key/value pair +*/ + void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_content*)) { if (ht == NULL) diff --git a/src/ht/ft_htget.c b/src/ht/ft_htget.c index 1562eb0..94a4164 100644 --- a/src/ht/ft_htget.c +++ b/src/ht/ft_htget.c @@ -13,9 +13,14 @@ #include "libft.h" #include "libft_ht.h" +/* +** Retrieve a value with associated key. +** Returns NULL if there is no value at `key`. +*/ + void *ft_htget(t_ftht *ht, char *key) { - + t_ftht_digest digest; t_ftlst *found; diff --git a/src/ht/ft_hthash.c b/src/ht/ft_hthash.c index e7e696c..ba922e7 100644 --- a/src/ht/ft_hthash.c +++ b/src/ht/ft_hthash.c @@ -12,6 +12,11 @@ #include "libft_ht.h" +/* +** Hash a string according to the size of the hash table. +*/ + +// maybe use a less efficient but understandable function t_ftht_digest ft_hthash(t_ftht *ht, char *key) { t_ftht_digest digest; diff --git a/src/ht/ft_htnew.c b/src/ht/ft_htnew.c index 6827c36..465eabf 100644 --- a/src/ht/ft_htnew.c +++ b/src/ht/ft_htnew.c @@ -13,6 +13,12 @@ #include "libft.h" #include "libft_ht.h" +/* +** Create a new hash table. +** `size` is the size of the underlying array of linked list (buckets) +** Return NULL is an allocation failed. +*/ + t_ftht *ft_htnew(t_ftsize size) { t_ftht *ht; diff --git a/src/ht/ft_htset.c b/src/ht/ft_htset.c index 81aba97..0755889 100644 --- a/src/ht/ft_htset.c +++ b/src/ht/ft_htset.c @@ -13,6 +13,13 @@ #include "libft.h" #include "libft_ht.h" +/* +** Create/Update a entry in an hash table. +** If `key` already exist in `ht`, updates only the list element content. +** else create a new list node in addition the list content. +** Return a pointer to the created entry, NULL if an allocation failed. +*/ + t_ftht_content *ft_htset(t_ftht *ht, char *key, void *value, void (*del)(t_ftht_content*)) { @@ -30,14 +37,13 @@ t_ftht_content *ft_htset(t_ftht *ht, char *key, void *value, if (tmp != NULL) { if (del != NULL) - (*del)(tmp->content); + del(tmp->content); tmp->content = content; return ((t_ftht_content*)tmp->content); } - if ((entry = ft_lstnew(content)) == NULL) { - free(content); + del(content); return (NULL); } ft_lstadd_front(ht->entries + digest, entry); diff --git a/src/ht/ft_inter_htkey_cmp.c b/src/ht/ft_inter_htkey_cmp.c index be2e52f..397177e 100644 --- a/src/ht/ft_inter_htkey_cmp.c +++ b/src/ht/ft_inter_htkey_cmp.c @@ -13,6 +13,10 @@ #include "libft.h" #include "libft_ht.h" +/* +** Hash table internal function to compare key string in linked list. +*/ + int ft_inter_htkey_cmp(const void *ref_key, const void *content) { if (ref_key == NULL || content == NULL) -- 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 --- src/ht/ft_htiter.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/ht/ft_htiter.c (limited to 'src/ht') diff --git a/src/ht/ft_htiter.c b/src/ht/ft_htiter.c new file mode 100644 index 0000000..5473412 --- /dev/null +++ b/src/ht/ft_htiter.c @@ -0,0 +1,17 @@ +#include "libft_ht.h" + +/* +** Iterate function `f` over every pair in `ht`. +*/ + +void ft_htiter(t_ftht *ht, void (*f)(t_ftht_content*)) +{ + size_t i; + + i = 0; + while (i < ht->size) + { + ft_lstiter(ht->entries[i], (void (*)(void*))f); + i++; + } +} -- 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 --- src/ht/ft_htcontent_new.c | 37 ------------------------------------- src/ht/ft_htdelone.c | 12 ++++++++---- src/ht/ft_htdestroy.c | 13 +++++++------ src/ht/ft_htentry_new.c | 37 +++++++++++++++++++++++++++++++++++++ src/ht/ft_htget.c | 12 +++++++----- src/ht/ft_hthash.c | 7 +++++-- src/ht/ft_htiter.c | 10 ++++++---- src/ht/ft_htnew.c | 12 ++++++------ src/ht/ft_htset.c | 36 ++++++++++++++++++++---------------- src/ht/ft_inter_htkey_cmp.c | 2 +- 10 files changed, 97 insertions(+), 81 deletions(-) delete mode 100644 src/ht/ft_htcontent_new.c create mode 100644 src/ht/ft_htentry_new.c (limited to 'src/ht') diff --git a/src/ht/ft_htcontent_new.c b/src/ht/ft_htcontent_new.c deleted file mode 100644 index 7dd4f20..0000000 --- a/src/ht/ft_htcontent_new.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_htcontent_new.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/01/30 08:45:36 by cacharle #+# #+# */ -/* Updated: 2020/02/17 04:09:50 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include "libft_ht.h" - -/* -** Create a new hash table key/value pair. -** `key` is always duplicated. -** Return a pointer to the created content or NULL is an allocation failed. -*/ - -t_ftht_content *ft_htcontent_new(char *key, void *value) -{ - t_ftht_content *content; - - if (key == NULL) - return (NULL); - if ((content = (t_ftht_content*)malloc(sizeof(t_ftht_content))) == NULL) - return (NULL); - if ((content->key = ft_strdup(key)) == NULL) - { - free(content); - return (NULL); - } - content->value = value; - return (content); -} diff --git a/src/ht/ft_htdelone.c b/src/ht/ft_htdelone.c index e3bb355..3672b23 100644 --- a/src/ht/ft_htdelone.c +++ b/src/ht/ft_htdelone.c @@ -13,13 +13,17 @@ #include "libft.h" #include "libft_ht.h" -/* -** Delete one hash table entry at `key`. +/** +** \brief Delete one hash table entry +** \param key Key of entry to delete +** \param del Function to destroy the entry +** \warning The del function HAS to free the key +** \note Do nothing if their is to entry which correspond to key */ -void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_content*)) +void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_entry*)) { - ft_lstremove_if(ht->entries + ft_hthash(ht, key), + ft_lstremove_if(ht->buckets + ft_hthash(ht, key), ft_inter_htkey_cmp, key, (void (*)(void*))del); } diff --git a/src/ht/ft_htdestroy.c b/src/ht/ft_htdestroy.c index a788a78..ef4b257 100644 --- a/src/ht/ft_htdestroy.c +++ b/src/ht/ft_htdestroy.c @@ -13,17 +13,18 @@ #include "libft.h" #include "libft_ht.h" -/* -** Destroy an hash table. -** The `del` function is used to destroy each key/value pair +/** +** \brief Destroy an hash table. +** \param del Function to delete each entry +** \warning The del function HAS to free the key */ -void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_content*)) +void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_entry*)) { if (ht == NULL) return ; while (ht->size-- > 0) - ft_lstclear(ht->entries + ht->size, (void (*)(void*))del); - free(ht->entries); + ft_lstdestroy(ht->buckets + ht->size, (void (*)(void*))del); + free(ht->buckets); free(ht); } diff --git a/src/ht/ft_htentry_new.c b/src/ht/ft_htentry_new.c new file mode 100644 index 0000000..03c0980 --- /dev/null +++ b/src/ht/ft_htentry_new.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_htentry_new.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/30 08:45:36 by cacharle #+# #+# */ +/* Updated: 2020/02/17 04:09:50 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" +#include "libft_ht.h" + +/** +** \brief Create a new hash table key/value pair. +** \param key Hash entry string key (always duplicated) +** \return Content or NULL if an allocation failed. +*/ + +t_ftht_entry *ft_htentry_new(char *key, void *value) +{ + t_ftht_entry *content; + + if (key == NULL) + return (NULL); + if ((content = (t_ftht_entry*)malloc(sizeof(t_ftht_entry))) == NULL) + return (NULL); + if ((content->key = ft_strdup(key)) == NULL) + { + free(content); + return (NULL); + } + content->value = value; + return (content); +} diff --git a/src/ht/ft_htget.c b/src/ht/ft_htget.c index 94a4164..6b5df48 100644 --- a/src/ht/ft_htget.c +++ b/src/ht/ft_htget.c @@ -13,9 +13,11 @@ #include "libft.h" #include "libft_ht.h" -/* -** Retrieve a value with associated key. -** Returns NULL if there is no value at `key`. +/** +** \brief Retrieve a value with a key +** \param ht Hash table where key is searched +** \param key Searched key +** \return Value void pointer at key or NULL if not found */ void *ft_htget(t_ftht *ht, char *key) @@ -27,8 +29,8 @@ void *ft_htget(t_ftht *ht, char *key) if (ht == NULL || key == NULL) return (NULL); digest = ft_hthash(ht, key); - found = ft_lstlfind(ht->entries[digest], ft_inter_htkey_cmp, key); + found = ft_lstlfind(ht->buckets[digest], ft_inter_htkey_cmp, key); if (found == NULL) return (NULL); - return (((t_ftht_content*)found->content)->value); + return (((t_ftht_entry*)found->data)->value); } diff --git a/src/ht/ft_hthash.c b/src/ht/ft_hthash.c index ba922e7..2670e31 100644 --- a/src/ht/ft_hthash.c +++ b/src/ht/ft_hthash.c @@ -12,8 +12,11 @@ #include "libft_ht.h" -/* -** Hash a string according to the size of the hash table. +/** +** \brief Hash a string +** \param ht So that the index is in the hash table bound +** \param key String to hash +** \return Hash */ // maybe use a less efficient but understandable function diff --git a/src/ht/ft_htiter.c b/src/ht/ft_htiter.c index 5473412..e5ab2eb 100644 --- a/src/ht/ft_htiter.c +++ b/src/ht/ft_htiter.c @@ -1,17 +1,19 @@ #include "libft_ht.h" -/* -** Iterate function `f` over every pair in `ht`. +/** +** \brief Iterate over entry of hash table +** \param ht Iterated hash table +** \param f Function applied to each entry */ -void ft_htiter(t_ftht *ht, void (*f)(t_ftht_content*)) +void ft_htiter(t_ftht *ht, void (*f)(t_ftht_entry*)) { size_t i; i = 0; while (i < ht->size) { - ft_lstiter(ht->entries[i], (void (*)(void*))f); + ft_lstiter(ht->buckets[i], (void (*)(void*))f); i++; } } diff --git a/src/ht/ft_htnew.c b/src/ht/ft_htnew.c index 465eabf..e28b544 100644 --- a/src/ht/ft_htnew.c +++ b/src/ht/ft_htnew.c @@ -13,10 +13,10 @@ #include "libft.h" #include "libft_ht.h" -/* -** Create a new hash table. -** `size` is the size of the underlying array of linked list (buckets) -** Return NULL is an allocation failed. +/** +** \brief Create a new hash table. +** \param size Size of the underlying array of linked list (buckets) +** \return Created hash table or NULL is an allocation failed */ t_ftht *ft_htnew(t_ftsize size) @@ -27,8 +27,8 @@ t_ftht *ft_htnew(t_ftsize size) return (NULL); if ((ht = (t_ftht*)malloc(sizeof(t_ftht))) == NULL) return (NULL); - ht->entries = (t_ftht_entry*)ft_calloc(size, sizeof(t_ftht_entry)); - if (ht->entries == NULL) + ht->buckets = (t_ftht_bucket*)ft_calloc(size, sizeof(t_ftht_entry)); + if (ht->buckets == NULL) { free(ht); return (NULL); diff --git a/src/ht/ft_htset.c b/src/ht/ft_htset.c index 0755889..9738c14 100644 --- a/src/ht/ft_htset.c +++ b/src/ht/ft_htset.c @@ -13,39 +13,43 @@ #include "libft.h" #include "libft_ht.h" -/* -** Create/Update a entry in an hash table. -** If `key` already exist in `ht`, updates only the list element content. -** else create a new list node in addition the list content. -** Return a pointer to the created entry, NULL if an allocation failed. +/** +** \brief Create/Update a entry in hash table. +** \note If `key` already exist in `ht`, only updates the list node content. +** Else create a new list node in addition the list content. +** \param ht Hash table where the entry is modified +** \param key Key of the new entry +** \param value Value of the new entry +** \param del Destroy function in case the entry is modified. +** \return Pointer to the created entry, NULL if an allocation failed. */ -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*)) { t_ftht_digest digest; - t_ftht_content *content; - t_ftht_entry entry; + t_ftht_entry *content; + t_ftht_bucket bucket; t_ftlst *tmp; if (ht == NULL || key == NULL) return (NULL); - if ((content = ft_htcontent_new(key, value)) == NULL) + if ((content = ft_htentry_new(key, value)) == NULL) return (NULL); digest = ft_hthash(ht, key); - tmp = ft_lstlfind(ht->entries[digest], ft_inter_htkey_cmp, key); + tmp = ft_lstlfind(ht->buckets[digest], ft_inter_htkey_cmp, key); if (tmp != NULL) { if (del != NULL) - del(tmp->content); - tmp->content = content; - return ((t_ftht_content*)tmp->content); + del(tmp->data); + tmp->data = content; + return ((t_ftht_entry*)tmp->data); } - if ((entry = ft_lstnew(content)) == NULL) + if ((bucket = ft_lstnew(content)) == NULL) { del(content); return (NULL); } - ft_lstadd_front(ht->entries + digest, entry); + ft_lstpush_front(ht->buckets + digest, bucket); return (content); } diff --git a/src/ht/ft_inter_htkey_cmp.c b/src/ht/ft_inter_htkey_cmp.c index 397177e..e8a0375 100644 --- a/src/ht/ft_inter_htkey_cmp.c +++ b/src/ht/ft_inter_htkey_cmp.c @@ -21,5 +21,5 @@ int ft_inter_htkey_cmp(const void *ref_key, const void *content) { if (ref_key == NULL || content == NULL) return (-1); - return (ft_strcmp((char*)ref_key, ((t_ftht_content*)content)->key)); + return (ft_strcmp((char*)ref_key, ((t_ftht_entry*)content)->key)); } -- 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 --- src/ht/ft_htdelone.c | 2 +- src/ht/ft_htdestroy.c | 2 +- src/ht/ft_htentry_new.c | 2 +- src/ht/ft_htget.c | 5 ++--- src/ht/ft_hthash.c | 2 +- src/ht/ft_htiter.c | 14 +++++++++++++- src/ht/ft_htnew.c | 2 +- src/ht/ft_htset.c | 7 ++++--- 8 files changed, 24 insertions(+), 12 deletions(-) (limited to 'src/ht') diff --git a/src/ht/ft_htdelone.c b/src/ht/ft_htdelone.c index 3672b23..7374a44 100644 --- a/src/ht/ft_htdelone.c +++ b/src/ht/ft_htdelone.c @@ -13,7 +13,7 @@ #include "libft.h" #include "libft_ht.h" -/** +/* ** \brief Delete one hash table entry ** \param key Key of entry to delete ** \param del Function to destroy the entry diff --git a/src/ht/ft_htdestroy.c b/src/ht/ft_htdestroy.c index ef4b257..ff362d2 100644 --- a/src/ht/ft_htdestroy.c +++ b/src/ht/ft_htdestroy.c @@ -13,7 +13,7 @@ #include "libft.h" #include "libft_ht.h" -/** +/* ** \brief Destroy an hash table. ** \param del Function to delete each entry ** \warning The del function HAS to free the key diff --git a/src/ht/ft_htentry_new.c b/src/ht/ft_htentry_new.c index 03c0980..12a1159 100644 --- a/src/ht/ft_htentry_new.c +++ b/src/ht/ft_htentry_new.c @@ -13,7 +13,7 @@ #include "libft.h" #include "libft_ht.h" -/** +/* ** \brief Create a new hash table key/value pair. ** \param key Hash entry string key (always duplicated) ** \return Content or NULL if an allocation failed. diff --git a/src/ht/ft_htget.c b/src/ht/ft_htget.c index 6b5df48..a6383fe 100644 --- a/src/ht/ft_htget.c +++ b/src/ht/ft_htget.c @@ -6,14 +6,14 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 08:33:21 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:21:09 by cacharle ### ########.fr */ +/* Updated: 2020/04/01 18:02:57 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" #include "libft_ht.h" -/** +/* ** \brief Retrieve a value with a key ** \param ht Hash table where key is searched ** \param key Searched key @@ -22,7 +22,6 @@ void *ft_htget(t_ftht *ht, char *key) { - t_ftht_digest digest; t_ftlst *found; diff --git a/src/ht/ft_hthash.c b/src/ht/ft_hthash.c index 2670e31..3369d24 100644 --- a/src/ht/ft_hthash.c +++ b/src/ht/ft_hthash.c @@ -12,7 +12,7 @@ #include "libft_ht.h" -/** +/* ** \brief Hash a string ** \param ht So that the index is in the hash table bound ** \param key String to hash diff --git a/src/ht/ft_htiter.c b/src/ht/ft_htiter.c index e5ab2eb..b854993 100644 --- a/src/ht/ft_htiter.c +++ b/src/ht/ft_htiter.c @@ -1,6 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_htiter.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/01 18:02:24 by charles #+# #+# */ +/* Updated: 2020/04/01 18:02:32 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft_ht.h" -/** +/* ** \brief Iterate over entry of hash table ** \param ht Iterated hash table ** \param f Function applied to each entry diff --git a/src/ht/ft_htnew.c b/src/ht/ft_htnew.c index e28b544..e5335d2 100644 --- a/src/ht/ft_htnew.c +++ b/src/ht/ft_htnew.c @@ -13,7 +13,7 @@ #include "libft.h" #include "libft_ht.h" -/** +/* ** \brief Create a new hash table. ** \param size Size of the underlying array of linked list (buckets) ** \return Created hash table or NULL is an allocation failed diff --git a/src/ht/ft_htset.c b/src/ht/ft_htset.c index 9738c14..68d3752 100644 --- a/src/ht/ft_htset.c +++ b/src/ht/ft_htset.c @@ -6,16 +6,17 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 08:41:52 by cacharle #+# #+# */ -/* Updated: 2020/02/28 12:11:00 by cacharle ### ########.fr */ +/* Updated: 2020/04/01 18:02:12 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" #include "libft_ht.h" -/** +/* ** \brief Create/Update a entry in hash table. -** \note If `key` already exist in `ht`, only updates the list node content. +** \note If `key` already exist in `ht` +** only updates the list node content. ** Else create a new list node in addition the list content. ** \param ht Hash table where the entry is modified ** \param key Key of the new entry -- cgit