Bugs in java.util.ArrayList, java.util.Hashtable and java.io.ByteArrayOutputStream

Martin Buchholz martinrb at google.com
Tue Mar 9 02:13:38 UTC 2010


On Fri, Mar 5, 2010 at 02:48, Kevin L. Stern <kevin.l.stern at gmail.com> wrote:
> Hi Martin,
>
> Thank you for your reply.  If I may, PriorityQueue appears to employ the
> simple strategy that I suggested above in its grow method:
>
>         int newCapacity = ((oldCapacity < 64)?
>                            ((oldCapacity + 1) * 2):
>                            ((oldCapacity / 2) * 3));
>         if (newCapacity < 0) // overflow
>             newCapacity = Integer.MAX_VALUE;
>
> It might be desirable to set a common strategy for capacity increase for all
> collections.

The PriorityQueue implementation is better than always doubling,
but not better enough to change the expansion policy of existing heavily used
collection classes.

Martin



More information about the core-libs-dev mailing list