gpt4 book ai didi

java - 哈希表的缺点

转载 作者:行者123 更新时间:2023-12-01 17:09:46 25 4
gpt4 key购买 nike

  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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com