wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collections : Help Needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Collections : Help Needed" Watch "Collections : Help Needed" New topic
Author

Collections : Help Needed

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
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...
Bing Qiao
Greenhorn

Joined: Oct 24, 2006
Posts: 21
I had doubt about that too.

But then I thought maybe it was due to the difference between Map and List.
Matthew Gerald
Greenhorn

Joined: Sep 11, 2006
Posts: 10
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.


-------------------------<br />SCJP 1.4 10/28/2006<br />SCWCD (next on the list!)
 
 
subject: Collections : Help Needed
 
Similar Threads
LinkedXXX vs XXX iteration speed
LinkedHashMap and LinkedList, iteration time doubt
LinkedList vs ArrayList
ArrayList vs. LinkedList
ArrayList vs LinkedList