• 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

Collections : Help Needed

 
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on Page 542 :
ArrayList : Choose this over a LinkedList when you need fast iteration but aren't as likely to be doing a lot of insertion and deletion.

AND

on page 544 : Although itwill be somewhat slower than HashMap for adding and removing elements, you can expect faster iteration with a LinkedHashMap.

This means that one must choose {ArrayList over LinkedList} and {LinkedHashMap over HashMap} for fast iteration. Is this correct or a typo (bug) as these 2 statements are oposite of each other...
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had doubt about that too.

But then I thought maybe it was due to the difference between Map and List.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found an interesting link here:

http://www.javafaq.nu/java-articles-archive-461.html

It seems as though the book is correct due to LinkedHashMap actually using a LinkedList for iteration purposes. So what I'm assuming is that the LinkedList iteration is faster than HashMap iteration. So, LinkedHashMap is then faster for iteration than HashMap due to using that LinkedList.
reply
    Bookmark Topic Watch Topic
  • New Topic