aboutsummaryrefslogtreecommitdiff
path: root/include/libft_ht.h
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-04-01 21:51:51 +0200
committerCharles <sircharlesaze@gmail.com>2020-04-01 21:58:05 +0200
commit65c5d5157e890e9f9445a94fb2d7f660e5492d8e (patch)
tree78613f26bdc531104c3e32d76ffcaf3c2f7013f5 /include/libft_ht.h
parentc128213daa677d548bfc2905496257fe4a4faf79 (diff)
parenta1675f56b35f5521a91851bae8ca650706374ae6 (diff)
downloadlibft-65c5d5157e890e9f9445a94fb2d7f660e5492d8e.tar.gz
libft-65c5d5157e890e9f9445a94fb2d7f660e5492d8e.tar.bz2
libft-65c5d5157e890e9f9445a94fb2d7f660e5492d8e.zip
Merge branch 'minishell'
Diffstat (limited to 'include/libft_ht.h')
-rw-r--r--include/libft_ht.h42
1 files changed, 28 insertions, 14 deletions
diff --git a/include/libft_ht.h b/include/libft_ht.h
index 62f2ee1..10c6fc7 100644
--- a/include/libft_ht.h
+++ b/include/libft_ht.h
@@ -6,28 +6,45 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/31 10:36:09 by cacharle #+# #+# */
-/* Updated: 2020/02/19 02:38:28 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
+*/
+
# 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,22 +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 (*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);