From aa9613efb6fb39bd96fc4836b5d38c3746af1b15 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 30 Jan 2020 10:36:49 +0100 Subject: hash table draft --- include/libft_ht.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 include/libft_ht.h (limited to 'include/libft_ht.h') diff --git a/include/libft_ht.h b/include/libft_ht.h new file mode 100644 index 0000000..bd67b47 --- /dev/null +++ b/include/libft_ht.h @@ -0,0 +1,53 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ht.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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 + +# include "libft.h" + +typedef struct +{ + char *key; + void *value; +} t_ftht_content; + +typedef t_list* t_ftht_entry; + +typedef struct +{ + t_ftsize size; + t_ftht_entry *entries; +} t_ftht; + +typedef t_ftuint t_ftht_digest; + + +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_value(t_ftht *ht); +t_ftht_content *ft_htget(t_ftht *ht, char *key); +t_ftht_content *ft_htset(t_ftht *ht, char *key, void *value); +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); + +/* +** internals +*/ + +void ft_inter_htdelcontent_key(t_ftht_content *content); +t_ftbool ft_inter_htkey_equal(char *ref_key, t_ftht_content *content); + +#endif -- cgit