rename hash functions to strhash functions

This commit is contained in:
Julian Daube 2017-10-25 18:38:33 +02:00
parent 30f97cf955
commit 5970eae220
3 changed files with 6 additions and 6 deletions

View File

@ -20,7 +20,7 @@ int key_compare(entry_key_t one, entry_key_t two) {
}
entry_hash_t key_hash(entry_key_t key) {
return hash_str(key) + 1; // make hash always nonzero
return strhash_str(key) + 1; // make hash always nonzero
}
hashtable_iterator_t hashtable_end(struct hashtable * table) {

View File

@ -10,15 +10,15 @@
// use rule:
// hash(i) = hash(i - 1) * 33 ^ str[i]
// see: http://www.cse.yorku.ca/~oz/hash.html
strhash_t hash_add(strhash_t hash, char c) {
strhash_t strhash_add(strhash_t hash, char c) {
return hash * 33 ^ c;
}
strhash_t hash_str(const char * str) {
strhash_t strhash_str(const char * str) {
strhash_t hash = 0;
while(*str) {
hash = hash_add(hash, *str);
hash = strhash_add(hash, *str);
str++;
}

View File

@ -13,10 +13,10 @@
typedef size_t strhash_t;
// "rehash" string with new char added to end
strhash_t hash_add(strhash_t hash, char c);
strhash_t strhash_add(strhash_t hash, char c);
/// hash a given string
strhash_t hash_str(const char * str);
strhash_t strhash_str(const char * str);