具有双重哈希和孪生素数的哈希表,没有二次哈希函数

Hashtable with double hashing and twin primes without secondary hash function

有人告诉我我们可以有一个没有任何辅助哈希函数和更大的孪生素数作为容量的双重哈希的哈希表。我想知道如何访问元素。

首先尝试使用以下方法获取索引:

index = hash % capacity

否则使用以下 attempt 从零开始的地方:

index = (hash + attempt++) % (capacity - 2)

我走在正确的轨道上吗?

我找到了答案。 "Data Structures and Other Objects Using C++ (4th Edition)" 的第 614 页描述了该方法: