File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Choosing the right collection Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Choosing the right collection" Watch "Choosing the right collection" New topic
Author

Choosing the right collection

O. Ziggy
Ranch Hand

Joined: Oct 02, 2005
Posts: 430

I am looking for a 'Summary' list of all the Java collections detailing the pros and cons of each. I am particularly interested in things like

- Which provide faster iteration
- Which provide faster search
- Which provide slower iteration
- Which provide faster insertion or removal


I have seen some sites by searching on Google but i am looking for just a summary preferable in table format.

Thanks in advance.
Arif Hossain
Greenhorn

Joined: Jun 07, 2006
Posts: 1
May be you have seen this page already, but it looked like a good summary to me.

Java Collections Overview
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9952
    
    6

Note that you are possibly going to have a hard time finding this..."fastest" is usually not something people care about. They generally care about how quickly time grows as the sample grows.

In other words, there may be a collection that always takes 20 seconds to return an element you are searching for. there may be another that take 1/100th of a second per element in the collection. Which is faster?

well, if I have 20 elements, option A takes 20 seconds, option b takes 1/5th of a second.

If i have 1,000,000 elements, option A takes 20 seconds. Option B takes about three hours.

Which collection is 'faster'? The answer is "it depends on your data set".


Never ascribe to malice that which can be adequately explained by stupidity.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Choosing the right collection
 
Similar Threads
Fastest iteration
Vector vs LinkedHashSet iteration speed
Iteration speed of Collections
StringBuilder slower than StringBuffer!?
How useful are tag libraries?