java - String 类中 hash32() 的用途是什么?

标签 java string

<分区>

谷歌搜索没有帮助我,所以我来到这里。 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/

相关文章:

java - 单元测试简单字函数

javascript - jQuery trim 功能在 IE7 中不起作用?

java - 安装向导出现错误编译错误 - 找不到符号

java - 未记录的 String.compareTo(null) NPE?

java - 让 ArrayList.get() 返回

java - Hibernate Criteria - 从两个没有任何关联的表中获取结果

java - 统计分析

php - 如果 default_charset 为空,字符集是什么

java - "\\\\".replaceAll( "\\\\", "\\") 抛出 java.lang.StringIndexOutOfBoundsException

java - 如何将 Android SDK 添加到 IntelliJ