【开源中国 APP 全新上线】“动弹” 回归、集成大模型对话、畅读技术报告”
private static int oldHash(int h) { h += ~(h << 9); h ^= (h >>> 14); h += (h << 4); h ^= (h >>> 10); return h; } private static int newHash(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); }
代码如上所示:这个是jdk1.5.0_15中的代码。
我想问的是 newHash和oldHash的算法核心是什么意思(最好能够说下代码意思的同时说下hash算法思想)? 小白表示没看懂,请高手解答下疑惑。