sna*_*nap 5 c string hash hash-function hashtable
我想构建一个哈希表,查找从1到15个字节的字节序列(字符串)中的键.
我想存储一个整数值,所以我想一个哈希数组就足够了.我很难概念化如何构造一个哈希函数,因为给定键会给出数组的索引.
任何援助都会受到很多关注.
散列中的最大条目数为:4081*15 + 4081*14 + ... 4081 = 4081((15*(16))/ 2)= 489720.
例如:
int table[489720];
int lookup(unsigned char *key)
{
int index = hash(key);
return table[index];
}
Run Code Online (Sandbox Code Playgroud)
哈希函数有什么好的选择,或者我将如何构建一个?
谢谢.