diff options
Diffstat (limited to 'graphs/piscine/hash_map/hash.c')
| -rw-r--r-- | graphs/piscine/hash_map/hash.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/graphs/piscine/hash_map/hash.c b/graphs/piscine/hash_map/hash.c new file mode 100644 index 0000000..434616f --- /dev/null +++ b/graphs/piscine/hash_map/hash.c @@ -0,0 +1,13 @@ +#include <stddef.h> + +size_t hash(const char *key) +{ + size_t i = 0; + size_t hash = 0; + + for (i = 0; key[i] != '\0'; ++i) + hash += key[i]; + hash += i; + + return hash; +} |
