Possible Duplicate:
Understanding strange Java hash function
static int hash(int h) {
// This function ensures that hashCodes that differ only by
// constant multiples at each bit position have a bounded
// number of collisions (approximately 8 at default load factor).
h ^= (h >>> 20) ^ (h >>> 12);
return h ^ (h >>> 7) ^ (h >>> 4);
}
I don't quite understand the algorithm principle of this implementation. Any explanation or any resouce I could refer to ? Thanks !
UPDATE
Thanks all for the answers and resouces. Actually I understand how hash works, yet but not konw why this code will ensure a bounded number of collisions
, as the comment says. Is there any theoretical verification?