Take the 2-minute tour ×

I am concerning that I am developing an application where I need to just validate the data from the hashtables. I have 8 hash tables and I get the data from them and verify it. All 8 hashtables has the same structure. My question is if I put data in 8 hashtables would it be more efficient or if I change it in one hashtable? Each hashtable has around 100 objects.

Thanks in advance.

Yours, Geek

share|improve this question

closed as not constructive by Craig P. Motlin, Tim, Barak, FelipeAls, Geobits Mar 4 '13 at 3:23


Efficiency -- how so? There's not even enough context to compare likelihood of collision. –  oldrinb Sep 11 '12 at 2:45
Performance revolving around a hundred elements in any data structure is not worth concerning yourself with. –  cheeken Sep 11 '12 at 2:48

1 Answer 1

up vote 0 down vote accepted

I agree that in this case the size is so small as to be insignificant.

That said, use a single hash table; otherwise you'd have to do 8 checks to find something, and have the overhead of 8 hash table structures (which by definition have an overhead for the slots used to perform well).

If you are using primitive types (or even just primitive types for keys in a map), I highly recommend the trove high performance collection library (GNU Trove). They are written for high performance computing, and in an environment like android can save you precious memory and compute cycles.

They are not complete drop-in replacements, but have comparable functionality...e.g.

TLongObjectHashMap<String> myMap; // a map from primitive long to strings 
myMap = new TLongObjectHashMap<String>();
myMap.put(4L, "Hello world"); // no boxing, so much less memory overhead, etc.
share|improve this answer
I was thinking in the same way but I want to confirm. –  Java Geek Sep 11 '12 at 4:26
