Comments (1)
丙哥,读了你的HashMap.md感觉收获满满,不过有两个地方我想提一下:
- 文中 “因为在使用不是2的幂的数字的时候,Length-1的值是所有二进制位全为1,这种情况下,index的结果等同于HashCode后几位的值。”一句中应该是“是2的幂”,Length-1才会全是1吧。
- “只要输入的HashCode本身分布均匀,Hash算法的结果就是均匀的。” 这里我觉得可以加上HashMap源码中对hashCode值的一个操作。
源码中对key的hash方法:static final int hash(Object key) { int h; return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16); }其中将原32位hashcode与其右移16位后的结果做了异或,为了让高16位也参与到“让hashcode分布更均匀”中,这样更能让hashcode分布均匀吧。
(第一次提issue,如有不妥,望丙哥告知🤓
好巧,我也注意到这个点了。
from javafamily.
Related Issues (20)
- A
- Spring循环依赖文章有一处错误 HOT 4
- java
- JavaFamily
- 枚举文章内容不完善
- 谁是原创呢 HOT 1
- 布隆过滤器解决的是缓存穿透
- 公众号的二维码失效了?
- HashMap有错字
- 敖丙
- 面试里自我介绍那篇链接不对,跳到20行代码那篇去了
- 大佬牛牛牛
- 人才交流群怎么进啊?
- 【项目自荐】: 📚JVM底层原理解析 + 面试知识点整理
- 【项目自荐】: ❤️一个基于Springboot的个人博客 HOT 1
- 全是相互抄 HOT 3
- 发神经了吗,干嘛一秒这么多回复!
- 目录中链接已失效 HOT 6
- 从二叉搜索树到B+树这个链接失效啦 HOT 6
- Js HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javafamily.