HashMap vs. TreeMap

Avinash Lakshman <[email protected]> Sun, 16 Dec 2007 01:04:11 -0600
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
Hi All

I need to store about a million key/value pairs. Which is more memory efficient HashMap or TreeMap? With the HashMap it looks like the resizing happens to be exponential but that is not the case with TreeMap i.e sometimes I may have 64,000 keys but the internal table allocated with the HashMap is at nearly double the value. I do not care about access times i.e I need a sparse HashMap. How can I acheive this? Can I think of the TreeMap as a poor man's sparse HashMap? Are there  any other implementations I could look at? Please advice.

Thanks
Avinash

_________________________________________________________________
Get the power of Windows + Web with the new Windows Live.
http://www.windowslive.com?ocid=TXT_TAGHM_Wave2_powerofwindows_122007
===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com