• 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

LinkedHash Map-Ordering garentee

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am using a LinkedHashMap to save the key-value pairs in the order in which they were inserted.There are scenarios when i use LinkedHashMap's keySet() method to iterate the Map,so when we use the KeySet() method which returns the Set object,is their a garuntee that the returned Set objects contains the keys in the order in which it was in the Hashmap(insertion order).Are there any performance issue in using the same??Please suggest and advice..


Thanks!
[ November 09, 2008: Message edited by: Bala'J'i Rags ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The key set is in insertion order, yes. Not sure what sort of performance issue you're thinking of here, but no special ones associated with the keySet() method.
 
Bala'J'i Rags
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ernest..I was concerned about the performance issue in using a Linked HashMap instead of HashMap (memory usage as well as the Speed factor of retreiving and inserting data into the Map)
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For any Map implementation, keySet(), entrySet() and values() return a view on the original Map. This means that additions to the Map are also noticable in these collections, and the order is always the same as that of the Map.
 
reply
    Bookmark Topic Watch Topic
  • New Topic