简体   繁体   English

Java-是否有其他备用第三方Collections(ArrayList等)库?

[英]Java - Is there any alternative, third-party Collections (ArrayList, etc.) libraries?

The story is that I'm now programming for Android. 故事是我现在正在为Android编程。

I found that ArrayList is really slow, especially when used with adapters for listviews, as sorting and searching are required for my project. 我发现ArrayList确实很慢,尤其是当与列表视图适配器一起使用时,因为排序和搜索是我的项目所必需的。 Is there any alternative library out there? 有没有其他替代库?

Thank you so much. 非常感谢。

As other answers have said, there are some alternative Collection libraries. 正如其他答案所说的那样,还有一些替代的Collection库。

However, in core your problem might not be the library but rather your own choice of Collection. 但是,核心问题不是库,而是您自己选择的Collection。 Using a different library, will not change this. 使用其他库将不会更改此设置。

In Java, and thus Android, you have a vast array of Collection choices to your disposal, all with different pro's and cons. 在Java中,因此在Android中,您可以使用各种各样的Collection选项,它们都有各自的优缺点。

This is a way to long story to write up, so unless you write down exactly what you want to do with it, no one can really tell you which choice is best. 这是写长篇小说的一种方法,因此,除非您确切地写下要使用的内容,否则没人会真正告诉您哪种选择是最佳的。 However, to give you a little start you could take a look at this; 但是,为了让您有所起点,您可以看一下。

收集树

Other than Collection framework in standard java API, below two are famous for their rich collection framework. 除了标准Java API中的Collection框架外,以下两个以其丰富的collection框架而闻名。

You can sort and search just fine with the existing Java collections. 您可以使用现有的Java集合进行排序和搜索。 I see no need for anything else. 我认为不需要任何其他东西。

But there are alternatives, like Google Collections and Apache Commons stuff. 但是,还有其他选择,例如Google Collections和Apache Commons之类的东西。

Drawback of ArrayList is that you cannot store primitives in it. ArrayList的缺点是您不能在其中存储基元。
Leading to much more memory usage compared to an array. 与阵列相比,导致更多的内存使用。
In Situation where you have very huge arrays (eg > ten or hundred thousands elemts) a growing primitive array is often the better solution. 在您有非常大的数组(例如,成千上万个元素)的情况下,增长原始数组通常是更好的解决方案。

This article shows to implement your own ArrayListLong using primitive types: 本文说明了使用基本类型实现自己的ArrayListLong

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

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