java 创建您自己的哈希图和哈希表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15460868/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 19:40:58  来源:igfitidea点击:

creating your own hashmap and hashtable

java

提问by Tuntun Gdfhjf

In a recent interview I was being asked how to write your own HashMap/Hashtableimplementation in Java.

在最近的一次采访中,我被问到如何用 Java编写自己的HashMap/Hashtable实现。

I have no idea of this so the only thing I said as a answer was that we can implement HashMapby using Array, because only this provides constant time access, if you know the index. Key is to writing hash function to minimize collision.

我不知道这一点,所以我作为答案说的唯一一件事是我们可以HashMap通过使用 Array来实现,因为只有它提供恒定时间访问,如果您知道索引。关键是编写散列函数以减少冲突。

Can you please advise me how we can write our own Hashmap/Hashtable?

你能告诉我如何写我们自己的Hashmap/Hashtable吗?