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

Ulf Zibis Ulf.Zibis at gmx.de
Tue Mar 9 23:11:06 UTC 2010


Am 09.03.2010 23:08, schrieb Martin Buchholz:
> On Tue, Mar 9, 2010 at 13:08, Ulf Zibis<Ulf.Zibis at gmx.de>  wrote:
>    
>> [1] current PriorityQueue snippet:
>> ...
>>          int newCapacity = ((oldCapacity<  64)?
>>                             ((oldCapacity + 1) * 2):
>>                             ((oldCapacity / 2) * 3));
>> ...
>> [2] new PriorityQueue snippet:
>> ...
>>          int newCapacity += (oldCapacity<  64) ?
>>                             oldCapacity : oldCapacity / 2;
>> ...
>>      
> Thanks, I took your suggestion and changed it to:
>
>          int newCapacity = oldCapacity + ((oldCapacity<  64) ?
>                                           (oldCapacity + 2) :
>                                           (oldCapacity>>  1));
>    

Oops :-[

Can you explain the mystery about "+ 2" ?

-Ulf





More information about the core-libs-dev mailing list