Java相当于C ++ std :: map? [英] Java equivalent of C++ std::map?

查看:188
本文介绍了Java相当于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):


  1. 插入/删除/搜索的性能

  2. 每个元素都由唯一键和映射值组成

  3. 键遵循严格的弱顺序



我正在寻找具有开源或设计文档的实现;

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆