[concurrency-interest] Questions about ArrayDeque

Doug Lea dl at cs.oswego.edu
Fri Jul 21 08:47:28 EDT 2006


Rémi Forax wrote:
> I have take a look to java.util.ArrayDeque today, and i have some 
> questions :
> 
> - Quoting the documentation :
>   "This class is likely to be faster than {@link Stack} when used as a 
> stack"
>   I used to use an ArrayList to implement a stack and
>   there is neither reference to ArrayList nor comparaison between
>   ArrayList and ArrayDeque in the documentation
>  
>   Is ArrayList is faster than ArrayQueue when used as a stack ?
> 

ArrayDeque should be at least as fast as ArrayList when used as pure stack.
Please tell us if you find otherwise. If nothing else, ArrayDeque has more
appropriate method names for uses as stack and queue.


> - I've found two methods (removeFirstOccurrence() and contains())
>    with mostly the same code.
>   Perhaps this code could be shared between them ?

It is logistically tricky to share small bits of code within
core Java classes, since it can interfere with more important
goal of being able to completely replace internal implementations
of various classes over time.

-Doug





More information about the Concurrency-interest mailing list