hash functions
hello i have a problem with making a code with a hash function
my method is
private int hash(String word)
{
int hashValue = 0;
for(int i = 0; i < word.length(); i++)
hashValue = ((hashValue << 5) + (word.charAt(i)-'a')) % M;
return hashValue;
}
however it only works for lowercase letters and i need it to work for numbers lowercase and uppercase
[427 byte] By [
Mykullski] at [2007-11-20 11:21:49]

# 2 Re: hash functions
What are you trying to hash? what would you consider a successful hash value?
Good teaching is more a giving of the right questions than a giving of the right answers...
J. Albers
dlorde at 2007-11-10 2:15:16 >

# 3 Re: hash functions
i figured it out sry
the code is
private int hash(String word)
{
int hashValue = 0;
for(int i = 0; i < word.length(); i++)
hashValue = ((hashValue << 6) + (word.charAt(i)-'0')) % M;
return hashValue;
}