双散列

数据结构与算法分析——c语言描述 第五章


static Position hash2(ElementType key, int tableSize) {
	return 7 - (key % 7);
}

Position find(ElementType key, HashTable h) {
	Position currentPos = hash(key, h->tableSize);
	int i = 0;
	while (h->theCells[currentPos].info != Empty && h->theCells[currentPos].element != key) {
		currentPos += (++i * hash2(key, h->tableSize));
		currentPos = currentPos % h->tableSize;
	}
	return currentPos;
}



你可能感兴趣的:(双散列)