changed hash functions names
This commit is contained in:
parent
c6cbcea963
commit
703bd4bef4
@ -39,7 +39,7 @@ void Hashtable_expand(Hashtable* ht){
|
||||
uint32 arlen=Autoarr_length(ar);
|
||||
for(uint16 k=0;k<arlen;k++){
|
||||
KVPair p=Autoarr_get(ar,k);
|
||||
uint16 newrown=ihash(p.key)%HT_HEIGHTS[ht->hein];
|
||||
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)));
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user