What is the best Java primitive collections library? (most memory and time efficient)
I've found Trove and FastUtil to be the most used ones, but haven't found much comparison between them (or between others)
Is there any comparison available?
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.
Collections are the framework used to store and manipulate a group of objects. Java Collection means a single unit of objects. Since the above two statements are true, generic Java collections can not store primitive types directly.
It's a combination of two facts: Java primitive types are not reference types (e.g. an int is not an Object ) Java does generics using type-erasure of reference types (e.g. a List<?> is really a List<Object> at run-time)
Since primitive types cannot be used in Collections or Generics, each time i is added to numbers a new Integer object is created.
This comparision between Java standard collections, Trove and Colt might be helpful.
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