5

I am developing android application in which I was using HashTable for storing KeyValue pair. At some stage I have to retrieve all values against keys. (I don't have thready safety issue). HashTable didn't satisfy performance as it started to take more time as data increases because of iteration. After some search on Google, I came to know about two following Apis for storing KeyValue.

Apache Commons Collection

Google Guava Collections

I have also checked this question Apache Commons vs. Guava (formerly "Google Collections")

But I want explanation more then just Generic support difference as in my case I am just using String, String for keyValue pair.

Should I go with any of them or I should use HashMap.

This link explain simple example of HashMap, Apache Commons, Google Guav collection. http://java.dzone.com/articles/hashmap-%E2%80%93-single-key-and

Community
  • 1
  • 1
K.Liaqat
  • 143
  • 1
  • 3
  • 14
  • 2
    A `Multimap` is not faster than a `Map`, it's "just" a specific use case (`Map>`). If you have to iterate on entries in a `HashMap`, there's nothing you can do to make it faster as it's already really straightforward: iterate on the buckets, and in each bucket iterate on the chained entries. – Frank Pavageau Nov 21 '14 at 11:58
  • 1
    There's not going to be a significant performance difference between these options. Use the option that's most readable. (I believe that's Guava, but then, I'm biased.) – Louis Wasserman Nov 21 '14 at 20:26
  • thanks @FrankPavageau and Louis for your time. By using Guava, I am able to significantly decrease time well almost 8 seconds. Now its taking me 6 seconds to load all data. I am focusing on other areas where I can improve – K.Liaqat Nov 22 '14 at 17:33

0 Answers0