Find array index from hashCode()
807588May 8 2009 — edited May 11 2009I am making a hash set for a project.
I am supposed to use java.lang.Object.hashCode() for the hash function. This returns any integer yes?
So my internal hash table is an array, with an array size much smaller than the size of integer.
Let's say the internal hash table has an array of 10 elements to start with, and the hash function returns 13, then it will find array index 3, because it reaches 9 and goes back to 0 for 10, 1 for 11 etc.
Is that a good idea?
So can I just use modulus?