简体   繁体   English

Java 数据结构/C++ STL 等价物?

[英]Java datastructures/ C++ STL equivalents?

I just started learning java.我刚开始学习java。 I already know C++ and python.我已经知道 C++ 和 python。 In order to learn Java, I am kinda drawing analogies from what I know in C++.为了学习 Java,我有点用我在 C++ 中所知道的做类比。 I was an avid user of STL libraries in C++ (vectors, deques, stacks, hashmaps) http://www.sgi.com/tech/stl/stl_introduction.html我是 C++ 中 STL 库的狂热用户(向量、双端队列、堆栈、哈希图) http://www.sgi.com/tech/stl/stl_introduction.html

At the same time, python also have standard dicts, lists etc easily figurable in their docs.同时,python 在他们的文档中也有标准的字典、列表等。

I have been googling lately to find STL equivalent in Java but am unable to find so?我最近一直在谷歌上搜索 Java 中的 STL 等价物,但找不到? Can someone point me to right resources?有人可以指出我正确的资源吗?

  1. std::vector -> juArrayList std::vector -> juArrayList
  2. std::unordered_map -> juHashMap std::unordered_map -> juHashMap
  3. std::map -> juTreeMap std::map -> juTreeMap
  4. std::set -> juLinkedHashSet std::set -> juLinkedHashSet
  5. std::unordered_set -> juHashSet std::unordered_set -> juHashSet
  6. std::stack -> juArrayDeque (juStack is deprecated), std::stack -> juArrayDeque(不推荐使用 juStack),
  7. std::queue -> use juLinkedList (also take a look on juArrayBlockingQueue). std::queue -> 使用 juLinkedList(也看看 juArrayBlockingQueue)。
  8. std::priority_queue -> juPriorityQueue std::priority_queue -> juPriorityQueue
  9. std::span -> no definite analogue std::span -> 没有明确的类似物
  10. std::deque -> juArrayDeque std::deque -> juArrayDeque
  11. std::list -> juLinkedList std::list -> juLinkedList
  12. std::forward_list -> no analogue std::forward_list -> 没有类似物

Important notice: the mentioned associations have similar API but may have different asymptotics of operations and implementation.重要提示:上述关联具有相似的 API,但可能具有不同的操作和实现渐近线。

Notice: ju means java.util .注意: ju表示java.util

Oracle explains it deeply here link Oracle深入解释了这里的链接

If you want to know about common containers, take a look at here link 如果您想了解常见容器,请查看此处链接

This is the official page for the Collections API: http://docs.oracle.com/javase/tutorial/collections/index.html 这是Collections API的官方页面: http//docs.oracle.com/javase/tutorial/collections/index.html

I'd also recommend the Thinking in Java book by Bruce Eckel. 我还推荐Bruce Eckel撰写的Thinking in Java一书。 (http://mindview.net/Books/TIJ4) The "Holding your objects chapter" provides an introduction and the "Containers in depth chapter" provides more information (including performance considerations). (http://mindview.net/Books/TIJ4)“持有你的对象章节”提供了一个介绍,“容器深度章节”提供了更多信息(包括性能考虑因素)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM