Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast String Collections in Java

I am using Java and I am looking for String Collections (Sets and Lists) that are optimized in space and are fast. My strings are of fixed size: either 3 or 5 chars long.

Please suggest to me if there are any collection libraries available that can be best suited to me. I was thinking of some dictionary based collections.

Thanks.

like image 691
niraj Avatar asked Aug 05 '10 19:08

niraj


People also ask

Which collection is best for performance Java?

The best general purpose or 'primary' implementations are likely ArrayList , LinkedHashMap , and LinkedHashSet . Their overall performance is better, and you should use them unless you need a special feature provided by another implementation. That special feature is usually ordering or sorting.

Which collection is best for searching data?

HashSet and LinkedHashSet have the best performance on search operations. The idea of the test is simple. First, an array of objects of my own class, MySimpleDate, is created. Then, an object of the to-be-tested collection class is created, and filled with all the objects from the array.


1 Answers

'dictionary based collections'? HashMap is default choice. It is as fast as O(1). And it has nothing with size of element fixed or not.

like image 188
卢声远 Shengyuan Lu Avatar answered Oct 17 '22 19:10

卢声远 Shengyuan Lu