java中数据结构的内部实现?
有没有一个来源可以找到 Java 中各种数据结构(HashMap、TreeSet 等)的详细实现信息。 例如:不同类型使用的哈希函数是什么?是开放寻址还是其他什么?类似的东西。
PS:我知道我可以查看源代码。但我会改天离开:)
Is there a source where I can find detailed implementation information of various data structures in Java (HashMaps, TreeSets etc.).
e.g: What is the hash function used for different types? Is it open addressing or something else? Similar stuff.
PS: I am aware that I can go through the source code. But that I will leave for some other day :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
由于 Java 是开源的,因此实现本身是最好看的。
如果您使用的是 Eclipse 并且已配置源代码,只需按 ctrl+左键单击所需的数据结构声明即可。 tt 将为此开源。
API 文档未提供实现细节。
Since Java is open source, the implementation itself is the best thing to look at.
If you are using Eclipse and have configured source code, just do ctrl+left click on required data structure declaration. tt will open source for that.
The API Documentation DOES NOT give implementation details.
从 Javadoc 开始,然后携带如果需要的话,请查看来源!
Start with the Javadoc and then carry on to the source if need be!
不知道你详细到什么程度了?
我可以告诉你什么对我来说就足够了。我总是从 NetBeans 获得它。在那里,我可以按住 CTRL 键,单击任何类名称,然后它就会转到它的代码。这样,您就可以将文档和代码集中在您面前的一个位置,并且您可以看到它们是如何实现的以及它们在文档中描述的内容。
希望有帮助。
编辑:
HashMap 中的第 247 行(在 HashSet 中创建然后在其中使用)描述了一个哈希函数,也许这就是您想要的?。
I do not know after what level of details you are?
I can tell you what is sufficient for me. I get it always from NetBeans. There I can, holding CTRL, click on any class name and it takes me to its code. This way you have documentation and code in one place in front of you and you can see how they have implemented, what they describe in the doc.
Hope it helps.
EDIT:
The line 247 in HashMap, which is created in HashSet then used in it, describes a hash function maybe this is what you want?.
您可以使用有关集合的文档:
http://download.oracle.com/javase/tutorial/collections/index.html
You can use documentation on Collections:
http://download.oracle.com/javase/tutorial/collections/index.html
不。API 文档定义了集合类的外部行为,但没有定义实现细节,这可能是特定于供应商的。如果你想知道这些类在特定虚拟机中是如何实现的,你别无选择,只能查看源代码。
至少据我所知,Java API 的实现没有提供针对此类特定细节的附加文档。
No. The API documentation defines the external behaviour of the collection classes, but not the implementation details, which probably are vendor specific. If you want to know how the classes are implemented in a specific VM, you have no other choice but to check the source code.
At least AFAIK, there is no implementation of the Java API with additional documentation available for such specific details.