<分区>
谷歌搜索没有帮助我,所以我来到这里。 String中的int hash32()
方法有什么用?顾名思义,它看起来像是一些散列,但它究竟是如何使用的,在什么地方使用的呢?
<分区>
谷歌搜索没有帮助我,所以我来到这里。 String中的int hash32()
方法有什么用?顾名思义,它看起来像是一些散列,但它究竟是如何使用的,在什么地方使用的呢?
最佳答案
答案正确here .以下是一些选择片段:
Java SE 7u6 introduces an improved, alternative hash function...
The alternative hash function improves the performance of these map implementations when a large number of key hash collisions are encountered.
The alternative hash function is only applied to keys of type String.
如@Slanec 所述,Java 8 对 HashMap
进行了一些更改。对于 Comparable
,将严重碰撞的性能下降减少到 O(lg n) 而不是 O(n)键,因此不再需要替代品 String
哈希。
关于java - String 类中 hash32() 的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23716836/