From 703bd4bef4a0f06d5606ddf785c0865e084f1157 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Sat, 7 May 2022 23:15:22 +0300 Subject: [PATCH] changed hash functions names --- Hashtable/Hashtable.c | 4 ++-- Hashtable/hash.c | 4 ++-- Hashtable/hash.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Hashtable/Hashtable.c b/Hashtable/Hashtable.c index 33ec495..d8c680b 100644 --- a/Hashtable/Hashtable.c +++ b/Hashtable/Hashtable.c @@ -39,7 +39,7 @@ void Hashtable_expand(Hashtable* ht){ uint32 arlen=Autoarr_length(ar); for(uint16 k=0;khein]; + uint16 newrown=hash32(p.key)%HT_HEIGHTS[ht->hein]; Autoarr(KVPair)* newar=newrows[newrown]; Autoarr_add(newar,p); } @@ -53,7 +53,7 @@ void Hashtable_expand(Hashtable* ht){ } Autoarr(KVPair)* getrow(Hashtable* ht, char* key, bool can_expand){ - uint32 hash=ihash(key); + uint32 hash=hash32(key); Autoarr(KVPair)* ar=ht->rows[hash%HT_HEIGHTS[ht->hein]]; if(can_expand && Autoarr_length(ar)==Autoarr_max_length(ar)) optime("expand",1,(Hashtable_expand(ht))); diff --git a/Hashtable/hash.c b/Hashtable/hash.c index 32ff34f..dfa6cb7 100644 --- a/Hashtable/hash.c +++ b/Hashtable/hash.c @@ -1,13 +1,13 @@ #include "hash.h" -uint32 ihash(char *str){ +uint32 hash32(char *str){ uint32 hash=5381; for (char c=*str;c;c=*(++str)) hash=((hash<<5)+hash)+c; return hash; } -uint64 lhash(char* str){ +uint64 hash64(char* str){ uint64 hash = 0; for (char c=*str;c;c=*(++str)) hash=c+(hash<<6)+(hash<<16)-hash; diff --git a/Hashtable/hash.h b/Hashtable/hash.h index 2f575c5..b3b7d2b 100644 --- a/Hashtable/hash.h +++ b/Hashtable/hash.h @@ -7,9 +7,9 @@ extern "C" { #include "../base/base.h" // djb2 hash function from http:// www.cse.yorku.ca/~oz/hash.html -uint32 ihash(char *str); +uint32 hash32(char *str); // sdbm hash function -uint64 lhash(char* str); +uint64 hash64(char* str); #if __cplusplus }