ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/ArrayList.java
(Generate patch)

Comparing jsr166/src/main/java/util/ArrayList.java (file contents):
Revision 1.12 by jsr166, Mon Nov 28 04:06:29 2005 UTC vs.
Revision 1.16 by jsr166, Tue Feb 7 20:54:24 2006 UTC

# Line 1 | Line 1
1   /*
2   * %W% %E%
3   *
4 < * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
4 > * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5   * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6   */
7  
8   package java.util;
9 import java.util.*; // for javadoc (till 6280605 is fixed)
9  
10   /**
11   * Resizable-array implementation of the <tt>List</tt> interface.  Implements
# Line 189 | Line 188 | public class ArrayList<E> extends Abstra
188       * @param minCapacity the desired minimum capacity
189       */
190      private void growArray(int minCapacity) {
191 <        if (minCapacity < 0)
192 <            throw new OutOfMemoryError(); // int overflow
191 >        if (minCapacity < 0) // overflow
192 >            throw new OutOfMemoryError();
193          int oldCapacity = elementData.length;
194          // Double size if small; else grow by 50%
195          int newCapacity = ((oldCapacity < 64)?
196                             ((oldCapacity + 1) * 2):
197 <                           ((oldCapacity * 3) / 2));
197 >                           ((oldCapacity / 2) * 3));
198 >        if (newCapacity < 0) // overflow
199 >            newCapacity = Integer.MAX_VALUE;
200          if (newCapacity < minCapacity)
201              newCapacity = minCapacity;
202          elementData = Arrays.copyOf(elementData, newCapacity);
# Line 685 | Line 686 | public class ArrayList<E> extends Abstra
686          }
687  
688          public boolean hasNext() {
689 <            return cursor < size;
689 >            return cursor != size;
690          }
691  
692          public boolean hasPrevious() {
693 <            return cursor > 0;
693 >            return cursor != 0;
694          }
695  
696          public int nextIndex() {
# Line 754 | Line 755 | public class ArrayList<E> extends Abstra
755          public void add(E e) {
756              if (expectedModCount != modCount)
757                  throw new ConcurrentModificationException();
758 <            ArrayList.this.add(cursor++, e);
759 <            lastRet = -1;
760 <            expectedModCount = modCount;
758 >            try {
759 >                ArrayList.this.add(cursor++, e);
760 >                lastRet = -1;
761 >                expectedModCount = modCount;
762 >            } catch (IndexOutOfBoundsException ex) {
763 >                throw new ConcurrentModificationException();
764 >            }
765          }
766      }
767   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines