Java 数据结构参考
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1274711/
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
Java Data Structures Reference
提问by Samuel Carrijo
Can anyone give me references of a web site containing a summary of the main Java data structures, and their respective complexity in time (for some given operations like add, find, remove), e.g. Hashtable
s are O(1) for finding, while LinkedList
s are O(n). Some details like memory usage would be nice too.
任何人都可以给我一个网站的参考,其中包含主要 Java 数据结构的摘要,以及它们各自的时间复杂度(对于某些给定的操作,如添加、查找、删除),例如Hashtable
s 是 O(1) 用于查找,而LinkedList
s在...上)。像内存使用这样的一些细节也会很好。
This would be really helpful for thinking in data structures for algorithms.
这对于思考算法的数据结构非常有帮助。
采纳答案by Matthew Nizol
Is there a reason to think that Java's implementation is different (in terms of complexity) than a generic, language agnostic implementation? In other words, why not just refer to a general reference on the complexity of various data structures:
是否有理由认为 Java 的实现(就复杂性而言)与通用的、与语言无关的实现不同?换句话说,为什么不只是参考有关各种数据结构复杂性的一般参考:
NIST Dictionary of Algorithms and Data Structures
But, if you insist on Java-specific:
但是,如果您坚持 Java 特定的:
Java standard data structures Big O notation
Java Collections cheatsheet V2(dead link, but this is the first version of the cheatsheet)
回答by jW.
I don't believe there is any single website outlining this (sounds like a good idea for a project though). I think part of the problem is that an understanding in how each of the algorithms runs is very important. For the most part, it sounds like you understand Big-O, so I would use that as your best guesses. Follow it up with some benchmarking/profiling to see what runs faster/slower.
我不相信有任何单一的网站概述了这一点(虽然听起来是一个项目的好主意)。我认为部分问题在于理解每个算法的运行方式非常重要。在大多数情况下,听起来您了解 Big-O,因此我会将其用作您的最佳猜测。跟进一些基准测试/分析,看看什么运行得更快/更慢。
And, yes, the Java docsshould have much of this information in java.util
.
而且,是的,Java 文档应该在java.util
.
回答by Eugene Ryzhikov
The most comprehensive Java Collections overview is here
最全面的 Java 集合概述在这里
回答by Steve B.
Time and space complexities for the main collection classes should correspond to data structures known time complexity. I don't think there's anything Java specific about it, e.g. (as you say) hash lookup should be O(1). You could look hereor here.
主要集合类的时间和空间复杂度应对应于已知时间复杂度的数据结构。我不认为有任何关于它的 Java 特定内容,例如(如您所说)哈希查找应该是 O(1)。你可以看看这里或这里。
回答by bluish
I found very useful The Collections Frameworkpage, expecially the Outline of the Collections Framework, where every interface/class is breeefly described. Unfortunately there's no big-O information.
我发现The Collections Framework页面非常有用,特别是 Collections Framework的大纲,其中简要描述了每个接口/类。不幸的是,没有大 O 信息。
回答by Opentuned
I couldn't see this particular resource mentioned here, i've found it of great use in the past. Know Thy Complexities!
我看不到这里提到的这个特定资源,我发现它在过去很有用。了解你的复杂性!