Joe Gottman wrote:
> Check the documentation of ArrayDeque
> (http://java.sun.com/javase/6/docs/ap...rayDeque.html). It's
> faster than LinkedList for inserting and deleting at either end. It
It actually doesn't say that. It says "faster than Stack" ... Stack is
synchronized. It says "faster than LinkedList when used as a Queue" ...
Queues are inserted at the end and removed from the head. That's not
inserting and deleting at either end.
The latter makes me wonder if ArrayDeques are implemented as circular
buffers. This might mean that the "offset" which get() would use is
likely to shift around. That offset also might change completely if the
underlying array fills up and has to be copied to a larger array.
(ArrayDeques are specified to grow as needed, they don't block or throw
errors related to being out of storage.)
> would also be faster than LinkedList for element access, if only the
> get() function were provided.
I think if you try implementing your own you'll find out exactly what
the issue is. I'll bet it's nasty too.