开链法(哈希桶)是解决哈希冲突的常用手法,结构如下:
数据结构的设计思路是这样的,定义一个K—V的链式节点(Node),以数组方式存储节点指针
实现代码如下:
#include<vector>
#include"HashTable.h"
size_t GetSize()
{
static size_t index = 0;
const int _PrimeSize = 28;
static const unsigned long _PrimeList[_PrimeSize] =
{
53ul, 97ul, 193ul, 389ul, 769ul,
1543ul, 3079ul, 6151ul, 12289ul, 24593ul,
49157ul, 98317ul, 196613ul, 393241ul, 786433ul,
1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul,
50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,
1610612741ul, 3221