struct Hash_map
{
static const int mask=0x7fffff;
int p[mask+1],q[mask+1];
void clear()
{
memset(q,0,sizeof(q));
}
int& operator [](int k)
{
int i;
for(i=k&mask;q[i]&&p[i]!=k;i=(i+1)&mask);//处理hash冲突
p[i]=k;
return q[i];
}
};
// BKDR Hash Function—BYVOID
unsigned int BKDRHash(char *str)
{
unsigned int seed = 131; // 31 131 1313 13131 131313 etc..
unsigned int hash = 0;
while (*str)
{
hash = hash * seed + (*str++);
}
return (hash & 0x7FFFFFFF);
}