views:

41

answers:

2

When deciding to use a specific container (List/Set/Map), I like to consider the performance (big-Oh notation) metrics of operations such as insert, delete, get, etc. This is so I can select the best container for my needs.

The API docs always specify synchronized/unsynchronized, but not other performance metrics.

Is there a table of reference anywhere that I can consult?

+5  A: 

Java Generics and Collections contains such data for all collection implementations.

Péter Török
I wish I could get something concise, summarized in table form...
Ovesh
+1  A: 

If you look at a specific implementation of one of the interfaces, it will give you performance information. Looking at ArrayList for example, you can read this:

The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation.

Peter Jaric
and where is it, for example, for Vector?
Ovesh
I could try something like "that's an old class and they didn't update the description when they retrofitted it to implement the List interface" but that would be lame and probably wrong. I will instead refer you to Péter Török's answer.
Peter Jaric