I have been using the Java documentation for OpenJDK 1.7, but I am not seeing a lot of information on Big-Oh notation in terms of complexities of operations between different container types, which is making it harder to know which is the most performance collection to use for my task at hand; for example, implementing a stack or a queue.
I have been using an ArrayDeque
for both just following my C++ instincts. The basics are there, such as ArrayList
is faster than LinkedList
, but there doesn't seem to be a consistent section for this. In C++ documentation, there is a section like the one below. Any Javadoc references that speak about complexities between containers would be helpful.
C++ example: http://en.cppreference.com/w/cpp/container/unordered_set/equal_range
Complexity
Average case constant, worst case linear in the size of the container.
Java Example: Embedded in the ArrayList documentation I found the following
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.