据我所知,在HashTable中,我们首先使用HashFunction将键转换为哈希码,然后使用模运算符将Hash code转换为整数索引,并使用模运算符获得HashTable中数据放置的位置。Key -> Hash Function -> Hash code -> Modulo operator -> integer index -> Store in HashTable
由于键是基于模运算符发出的索引存储的
在Dan著名的Djb2散列函数中,我看到它更倾向于使用逐位运算符,但是为什么在简单的乘法中使用它呢?会更快吗?(散列<< 5) +散列=散列* 33unsigned int hash(const char *word) // Djb2 hashfunction by Dan Bernstein int c;
while ((c