• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

which is more efficient?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and Welcome to JavaRanch ajm jsk !
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic