From aa9613efb6fb39bd96fc4836b5d38c3746af1b15 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 30 Jan 2020 10:36:49 +0100 Subject: hash table draft --- src/ht/ft_hthash.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/ht/ft_hthash.c (limited to 'src/ht/ft_hthash.c') diff --git a/src/ht/ft_hthash.c b/src/ht/ft_hthash.c new file mode 100644 index 0000000..66f8efb --- /dev/null +++ b/src/ht/ft_hthash.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_hthash.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/30 09:56:01 by cacharle #+# #+# */ +/* Updated: 2020/01/30 10:34:27 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +t_ftht_digest ft_hthash(t_ftht *ht, char *key) +{ + t_ftht_digest digest; + + if (*key == '\0') + return (0); + digest = *key++ << 7; + while (*key != '\0') + { + digest = ((1000003 * digest) ^ *key) & (1<<32); + key++; + } + return (digest); +} -- cgit