New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
面经手册 · 第3篇《HashMap核心知识,扰动函数、负载因子、扩容链表拆分,深度学习》 - bugstack虫洞栈 #126
Comments
总结上面3行 hash&oldCap应该是不为0 |
对头,笔误了,“ hash & oldCap 不为0,则被迁移到下标位置24。”小哥认真😄 |
2.2.2 扰动函数散列图表 以上的两张图 应改为 以下的两张图 |
赞!收到!😄 |
3.1 计算过程: @Test
public void test_threshold() {
System.out.println(tableSizeFor(17));
}
static int tableSizeFor(int cap) {
int n = cap - 1;
System.out.println(Integer.toBinaryString(n));
n |= n >>> 1;
System.out.println(Integer.toBinaryString(n));
n |= n >>> 2;
System.out.println(Integer.toBinaryString(n));
n |= n >>> 4;
System.out.println(Integer.toBinaryString(n));
n |= n >>> 8;
System.out.println(Integer.toBinaryString(n));
n |= n >>> 16;
System.out.println(Integer.toBinaryString(n));
return (n < 0) ? 1 : (n >= (1 << 30)) ? (1 << 30) : n + 1;
} |
记录: |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://bugstack.cn/interview/2020/08/07/%E9%9D%A2%E7%BB%8F%E6%89%8B%E5%86%8C-%E7%AC%AC3%E7%AF%87-HashMap%E6%A0%B8%E5%BF%83%E7%9F%A5%E8%AF%86-%E6%89%B0%E5%8A%A8%E5%87%BD%E6%95%B0-%E8%B4%9F%E8%BD%BD%E5%9B%A0%E5%AD%90-%E6%89%A9%E5%AE%B9%E9%93%BE%E8%A1%A8%E6%8B%86%E5%88%86-%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0.html
散列表实现?扰动函数?初始化容量?负载因子?扩容元素拆分?🕵HashMap理论学习+实践验证,让懂了就是真的懂!
The text was updated successfully, but these errors were encountered: