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.
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.
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.
'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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With