com.google.common.collect.Ordering.profit 在 64 位地址空间中可靠吗?
com.google.common.collect. Arbitration()
声称可以通过 System.identityHashCode(Object)
对任意对象进行可靠的比较。然而,由于 hashCode 是一个 32 位数量,我不知道这如何在 64 位地址空间中工作,其中可能有超过 2**32 个对象实例。我的怀疑有道理吗?
com.google.common.collect.arbitrary()
claims to produce a reliable comparison of arbitrary objects via System.identityHashCode(Object)
. However, since the hashCode is a 32-bit quantity, I don't see how this could work in a 64-bit address space, where there may be more than 2**32 object instances. Is my skepticism justified?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
源代码显示,如果不同对象的两个身份哈希码之间发生冲突,比较器会回退到将每个对象与计数器相关联的映射,每次在映射中存储新对象时,计数器都会递增。
请参阅http://docs.guava-libraries.googlecode.com/git-history/v11.0.1/javadoc/src-html/com/google/common/collect/Ordering.html#line.200< /a>
The source code reveals that in case of a collision between two identity hash codes of different objects, the comparator falls back to a map associating each of the objects with a counter that is incremented each time a new object is stored in the map.
See http://docs.guava-libraries.googlecode.com/git-history/v11.0.1/javadoc/src-html/com/google/common/collect/Ordering.html#line.200