question about string hash function

Thread Starter

moslem

Joined Dec 16, 2009
20
Hello every one,
i've a string hash function it's performace is already good but there is some things that happens inside it and idon't know why
the hash function:
unsigned int table::hash(const string &word)
{
int hash = 0;
int n=word.length();
for(int i=0;i<n;i++)
hash = 31*hash+word;
return hash % MAX_TABLE;
}
my questions about it
why we multiply by 31 the hash every time is this for making weighting for the characters or any thing else?
thanks inadvance.
 
Top