什么是最有效的 Java Collections 库? [英] What is the most efficient Java Collections library?

查看:21
本文介绍了什么是最有效的 Java Collections 库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最高效的 Java 集合库是什么?

What is the most efficient Java Collections library?

几年前,我做了很多 Java,当时的印象是 trove最佳(最高效)Java 集合实现.但是当我阅读最有用的免费 Java 库?"这个问题的答案时,我注意到 trove 几乎没有被提及.那么现在哪个 Java Collections 库最好?

A few years ago, I did a lot of Java and had the impression back then that trove is the best (most efficient) Java Collections implementation. But when I read the answers to the question "Most useful free Java libraries?" I noticed that trove is hardly mentioned. So which Java Collections library is best now?

更新:澄清一下,我主要想知道当我必须在哈希表等中存储数百万个条目时使用什么库(需要小的运行时和内存占用).>

UPDATE: To clarify, I mostly want to know what library to use when I have to store millions of entries in a hash table etc. (need a small runtime and memory footprint).

推荐答案

从检查来看,Trove 看起来只是一个原始类型的集合库——它并不是要在普通集合上添加很多功能在 JDK 中.

From inspection, it looks like Trove is just a library of collections for primitive types - it's not like it's meant to be adding a lot of functionality over the normal collections in the JDK.

就个人而言(而且我有偏见)我喜欢 Guava(包括以前的 Google Java Collections 项目).它使各种任务(包括集合)变得更容易,至少以一种合理有效的方式.鉴于集合操作很少在我的代码中形成瓶颈(以我的经验),这比集合 API更好",集合 API 可能更有效但不会使我的代码具有可读性.

Personally (and I'm biased) I love Guava (including the former Google Java Collections project). It makes various tasks (including collections) a lot easier, in a way which is at least reasonably efficient. Given that collection operations rarely form a bottleneck in my code (in my experience) this is "better" than a collections API which may be more efficient but doesn't make my code as readable.

鉴于 Trove 和 Guava 之间的重叠几乎为零,也许您可​​以从收藏库中澄清您实际要寻找的内容.

Given that the overlap between Trove and the Guava is pretty much nil, perhaps you could clarify what you're actually looking for from a collections library.

这篇关于什么是最有效的 Java Collections 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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