• 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

Comparison of LinkedHashMap & HashMap

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there.Just looking on page 544 of the (Highly revered )
K&B SCJP book and in relation to LinkedHashMap, I see that
the text states that LinkedHashMap is quicker than HashMap
for adding and removing elements. Im just wondering, how so?
Many thanks & best regards.
K
[ June 19, 2008: Message edited by: Keith Nagle ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm... According to Eckel's Thinking in Java, Choosing between Maps...

LinkedHashMap is slightly slower than HashMap because it maintains the linked list in addition to the hashed data structure.


Of course, the comparisons Eckel provides come with a disclaimer: "...this will be different according to the computer and JVM you are using..." And if you study the table of test results he provides, you will also see that the size of the Map makes a difference.
 
Keith Nagle
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great stuff marc.
Thank you very much.
reply
    Bookmark Topic Watch Topic
  • New Topic