This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Performance and the fly likes which is more efficient? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "which is more efficient?" Watch "which is more efficient?" New topic
Author

which is more efficient?

ajm jsk
Greenhorn

Joined: Apr 07, 2009
Posts: 1
i have two data structures, one is int(key) and another is list of int's (value).
I am just thinking that out of all the data structures that java has, which one will be more efficient here to use as a key value pair?

( treemap, map, hashmap, etc)
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Map is an abstract data type. HashMap, TreeMap, IdentityHashMap etc are implementation of Map.

now question is which is efficient? it is entirely depends on your situation. each implementation has its own tradeoff.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

and Welcome to JavaRanch ajm jsk !
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

Why does it matter? Odds are the difference in speed will be imperceptible for any application you will write. What you should be focusing on is what makes the most sense - what is easiest to write, what is easiest to understand, and what is easiest to maintain.

Picking a data structure based on some ill-defined efficiency need is guaranteed to cause you more headaches than it is ever going to be worth.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: which is more efficient?
 
Similar Threads
How to implement a Object pool in java
2 approaches, which to choose?
Can a string array member serve as an index number of another string array?
Data Structures and Algorithm Analysis
any object better than hashmap