File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
REST with Spring (video course)
this week in the
HashMap vs TreeMap data retrival.
Joined: Apr 06, 2007
Jul 06, 2007 05:06:00
What is the best data structure to use to retrieve data from a map of data
? There are about 40000 objects in a Map with index of Integer values.
I heard that even though
is sorted, it has nothing to do with data
any idea please.
Jesper de Jong
Joined: Aug 16, 2005
Jul 06, 2007 06:27:00
There is ofcourse not one data structure that is better than the other one for all purposes. It depends on what you are doing. If you want the data to be sorted on keys, use
. Otherwise use
is faster than
for get and put operations. From the JavaDoc of
"This implementation provides
for the basic operations (get and put), assuming the hash function disperses the elements properly among the buckets."
From the JavaDoc of
"This implementation provides guaranteed
cost for the containsKey, get, put and remove operations."
Java Beginners FAQ
JavaRanch SCJP FAQ
The Java Tutorial
Java SE 8 API documentation
I agree. Here's the link:
subject: HashMap vs TreeMap data retrival.
Sort a Map on the <Key>.
Map: no duplicates allowed?
hashmap key values
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015