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.13 by dl, Mon Nov 28 23:53:32 2005 UTC

# Line 189 | Line 189 | public class ArrayList<E> extends Abstra
189       * @param minCapacity the desired minimum capacity
190       */
191      private void growArray(int minCapacity) {
192 <        if (minCapacity < 0)
193 <            throw new OutOfMemoryError(); // int overflow
192 >        if (minCapacity < 0) // overflow
193 >            throw new OutOfMemoryError();
194          int oldCapacity = elementData.length;
195          // Double size if small; else grow by 50%
196          int newCapacity = ((oldCapacity < 64)?
197                             ((oldCapacity + 1) * 2):
198 <                           ((oldCapacity * 3) / 2));
198 >                           ((oldCapacity / 2) * 3));
199 >        if (newCapacity < 0) // overflow
200 >            newCapacity = Integer.MAX_VALUE;
201          if (newCapacity < minCapacity)
202              newCapacity = minCapacity;
203          elementData = Arrays.copyOf(elementData, newCapacity);
# Line 685 | Line 687 | public class ArrayList<E> extends Abstra
687          }
688  
689          public boolean hasNext() {
690 <            return cursor < size;
690 >            return cursor != size;
691          }
692  
693          public boolean hasPrevious() {
694 <            return cursor > 0;
694 >            return cursor != 0;
695          }
696  
697          public int nextIndex() {
# Line 754 | Line 756 | public class ArrayList<E> extends Abstra
756          public void add(E e) {
757              if (expectedModCount != modCount)
758                  throw new ConcurrentModificationException();
759 <            ArrayList.this.add(cursor++, e);
760 <            lastRet = -1;
761 <            expectedModCount = modCount;
759 >            try {
760 >                ArrayList.this.add(cursor++, e);
761 >                lastRet = -1;
762 >                expectedModCount = modCount;
763 >            } catch (IndexOutOfBoundsException ex) {
764 >                throw new ConcurrentModificationException();
765 >            }
766          }
767      }
768   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines