/* * strhash.c * * Created on: 21.10.2017 * Author: julian */ #include "strhash.h" // use rule: // hash(i) = hash(i - 1) * 33 ^ str[i] // see: http://www.cse.yorku.ca/~oz/hash.html strhash_t strhash_add(strhash_t hash, char c) { return hash * 33 ^ c; } strhash_t strhash_str(const char * str) { strhash_t hash = 0; while(*str) { hash = strhash_add(hash, *str); str++; } return hash; }