• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which is more efficient?

 
ajm jsk
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and Welcome to JavaRanch ajm jsk !
 
fred rosenberger
lowercase baba
Bartender
Posts: 12083
29
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic