This is a prefix hashing function. i want to count the number of collisions in this method but i am not sure how to do it. It seems like it might be simple but i just cant think of a great way to do it....
int HashTable_qp::preHash(string & key, int tableSize )
{
string pad = "AA";
//some words in the input are less than 3 letters
//I choose to pad the string with A because all padded characters
//have same ascii val, which is low, and will hopefully alter the results less
if (key.length() < 3)
{
key.append(pad);
}
return ( key[0] + 27 * key[1] + 729 * key[2] ) % tableSize;
}