--- jsr166/src/main/java/util/ArrayList.java 2005/11/27 14:54:23 1.9 +++ jsr166/src/main/java/util/ArrayList.java 2005/11/28 04:06:29 1.12 @@ -189,7 +189,7 @@ public class ArrayList extends Abstra * @param minCapacity the desired minimum capacity */ private void growArray(int minCapacity) { - if (minCapacity < 0) + if (minCapacity < 0) throw new OutOfMemoryError(); // int overflow int oldCapacity = elementData.length; // Double size if small; else grow by 50% @@ -414,7 +414,7 @@ public class ArrayList extends Abstra modCount++; if (s >= elementData.length) growArray(s + 1); - System.arraycopy(elementData, index, + System.arraycopy(elementData, index, elementData, index + 1, s - index); elementData[index] = element; size = s + 1; @@ -437,7 +437,7 @@ public class ArrayList extends Abstra E oldValue = (E)elementData[index]; int numMoved = s - index; if (numMoved > 0) - System.arraycopy(elementData, index + 1, + System.arraycopy(elementData, index + 1, elementData, index, numMoved); elementData[s] = null; size = s; @@ -602,7 +602,7 @@ public class ArrayList extends Abstra for (int i=0; i extends Abstra throw new ConcurrentModificationException(); } } + public E previous() { try { int i = cursor - 1; - E next = get(i); + E prev = get(i); lastRet = i; cursor = i; - return next; + return prev; } catch (IndexOutOfBoundsException ex) { throw new NoSuchElementException(); } finally { - if (modCount != expectedModCount) + if (expectedModCount != modCount) throw new ConcurrentModificationException(); } } @@ -732,7 +733,7 @@ public class ArrayList extends Abstra public void remove() { if (lastRet < 0) throw new IllegalStateException(); - if (modCount != expectedModCount) + if (expectedModCount != modCount) throw new ConcurrentModificationException(); ArrayList.this.remove(lastRet); if (lastRet < cursor) @@ -744,19 +745,18 @@ public class ArrayList extends Abstra public void set(E e) { if (lastRet < 0) throw new IllegalStateException(); - if (modCount != expectedModCount) + if (expectedModCount != modCount) throw new ConcurrentModificationException(); ArrayList.this.set(lastRet, e); expectedModCount = modCount; } public void add(E e) { - if (modCount != expectedModCount) + if (expectedModCount != modCount) throw new ConcurrentModificationException(); ArrayList.this.add(cursor++, e); lastRet = -1; expectedModCount = modCount; } } - }