java - 哈希表的缺点

标签 java hashtable

  1. 哈希表中可以有任意数量的记录吗?
  2. 如果我们有更多记录(例如大约 10000 条记录),使用 Hashtable 是否有效?

使用 Hashtable 在效率方面有什么缺点吗?

谢谢。

最佳答案

disadvantage HashTable的效率为:

Hash tables become quite inefficient when there are many collisions. While extremely uneven hash distributions are extremely unlikely to arise by chance, a malicious adversary with knowledge of the hash function may be able to supply information to a hash that creates worst-case behavior by causing excessive collisions, resulting in very poor performance, e.g. a denial of service attack.[21] In critical applications, universal hashing can be used; a data structure with better worst-case guarantees may be preferable.[22]

您可以使用 HashMap,因为它们比 HashTable 更好,是一个不错的选择。

关于java - 哈希表的缺点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24261326/

相关文章:

java - 使用Guava Cache在多个服务实例上进行分布式缓存同步

c - 出现段错误 11 不确定在 C 中是否正确使用指针

c++ - 创建更好的哈希函数

java - 哈希表中的键有时会相互冲突是否正常?

c# - 在 O(1) 中实现具有基于键和基于索引的访问的哈希表

java - 为什么这个广播接收器不起作用?

Java 原始类型提升困惑

java - 使用@Reference 注释在运行时动态选择服务实现?

java - 工程 OOP 模型,您可以在其中注册类类型的处理程序

haskell - 修改 ST Monad 中的哈希表