0

HashMap.java メソッド内のハッシュ

        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);
        } 

// メソッドハッシュ

ハッシュコードを計算した後、右シフトとビット単位の「排他的論理和」演算子はほとんどありません. 数値を選択する理由はありますか("20"&"12")?"7"&"4"

        h ^= (h >>> 20) ^ (h >>> 12);
        return h ^ (h >>> 7) ^ (h >>> 4);

間違いなく h はスクランブルです。これが正確に解決されていることを説明するのに役立ちますか?

4

0 に答える 0