HashMap的hash()方法求祥解

昨天閒來無事看HashMap的源代碼,看到這裏hash()方法,自己都搞不懂爲什麼是這個算法,有哪位大俠指點指點,謝謝了
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);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章