Java相当于C ++ std :: map? [英] Java equivalent of C++ std::map?
问题描述
我正在寻找一个具有C ++ std :: map的特性的Java类(我理解它是一个自平衡的二叉搜索树):
I'm looking for a Java class with the characteristics of C++ std::map's usual implementation (as I understand it, a self-balancing binary search tree):
- 插入/删除/搜索的性能
- 每个元素都由唯一键和映射值组成
- 键遵循严格的弱顺序
我正在寻找具有开源或设计文档的实现;
I'm looking for implementations with open source or design documents; I'll probably end up rolling my own support for primitive keys/values.
这个问题的风格类似于: Java等效的std :: deque ,它的答案是ArrayDeque从Java的基本集合。
This question's style is similar to: Java equivalent of std::deque, whose answer was "ArrayDeque from Primitive Collections for Java".
推荐答案
ConcurrentSkipListMap 是由跳过列表(具有O(log n)性能的自平衡树状结构)支持的排序映射。通常,CSLM的边界比TreeMap(这是一个自平衡的红黑树括号)更紧密,因此它可能表现更好,具有线程安全和并发的优点,而TreeMap不是。 CSLM已添加到JDK 1.6中。
ConcurrentSkipListMap is a sorted map backed by a skip list (a self-balancing tree-like structure with O(log n) performance). Generally the bounds on CSLM are tighter than TreeMap (which is a self-balancing red-black tree impl) so it will probably perform better, with the side benefit of being thread-safe and concurrent, which TreeMap is not. CSLM was added in JDK 1.6.
Trove 具有一组用于原始类型的集合以及常见Java集合类型的一些其他有趣的变体。
Trove has a set of collections for primitive types and some other interesting variants of the common Java collection types.
其他感兴趣的集合库包括 Google集合库和 Apache Commons Collections 。
Other collection libraries of interest include the Google Collection library and Apache Commons Collections.
这篇关于Java相当于C ++ std :: map?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!