On Sun, 19 Feb 2012 03:39:48 -0800, Roedy Green
<see_w...@mindprod.com.invalid> wrote:
>It has always bothered me that you have to pay such a high speed
>penalty for ArrayLists when most of the time do nothing but access an
>array for you.
>
>What If ArrayLists were looked on more as primitives and implemented
>as RAW arrays. When you got an ArrayIndexOutOfBoundsException, code
>would jump into grow the array, but most of the time It would just
>stay out the way.
I haven't looked at the Java ArrayList code.
One could have a RAW array and if you got an
ArrayIndexOutOfBoundsException, another RAW array could be allocated
with more complicated indexing since you would need to know when you
are in the first or n'th RAW array.
When the ArrayList is idle (JVM has idel time?), then the RAW array
segments could be coalesced, giving a better amortized behaviour.
--
Regards,
Casey