--- jsr166/src/main/java/util/ArrayList.java 2005/11/28 23:53:32 1.13 +++ jsr166/src/main/java/util/ArrayList.java 2006/03/19 17:25:10 1.17 @@ -1,12 +1,11 @@ /* * %W% %E% * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package java.util; -import java.util.*; // for javadoc (till 6280605 is fixed) /** * Resizable-array implementation of the List interface. Implements @@ -123,31 +122,12 @@ public class ArrayList extends Abstra /** * Constructs a list containing the elements of the specified * collection, in the order they are returned by the collection's - * iterator. The ArrayList instance has an initial capacity of - * 110% the size of the specified collection. + * iterator. * * @param c the collection whose elements are to be placed into this list * @throws NullPointerException if the specified collection is null */ public ArrayList(Collection c) { - int size = c.size(); - // 10% for growth - int cap = ((size/10)+1)*11; - if (cap > 0) { - Object[] a = new Object[cap]; - a[size] = a[size+1] = UNALLOCATED; - Object[] b = c.toArray(a); - if (b[size] == null && b[size+1] == UNALLOCATED) { - b[size+1] = null; - elementData = b; - this.size = size; - return; - } - } - initFromConcurrentlyMutating(c); - } - - private void initFromConcurrentlyMutating(Collection c) { elementData = c.toArray(); size = elementData.length; // c.toArray might (incorrectly) not return Object[] (see 6260652) @@ -155,8 +135,6 @@ public class ArrayList extends Abstra elementData = Arrays.copyOf(elementData, size, Object[].class); } - private final static Object UNALLOCATED = new Object(); - /** * Trims the capacity of this ArrayList instance to be the * list's current size. An application can use this operation to minimize @@ -190,7 +168,7 @@ public class ArrayList extends Abstra */ private void growArray(int minCapacity) { if (minCapacity < 0) // overflow - throw new OutOfMemoryError(); + throw new OutOfMemoryError(); int oldCapacity = elementData.length; // Double size if small; else grow by 50% int newCapacity = ((oldCapacity < 64)?