Author: scolebourne
Date: Sun Jul 24 16:03:31 2005
New Revision: 224667
URL: http://svn.apache.org/viewcvs?rev=224667&view=rev
Log:
Fix iterator.remove() to work correctly after previous() - commons-collections
test tightening
Modified:
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessBooleanList.java
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessByteList.java
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessCharList.java
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessDoubleList.java
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessFloatList.java
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessIntList.java
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessLongList.java
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessShortList.java
Modified:
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessBooleanList.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessBooleanList.java?rev=224667&r1=224666&r2=224667&view=diff
==============================================================================
---
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessBooleanList.java
(original)
+++
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessBooleanList.java
Sun Jul 24 16:03:31 2005
@@ -283,14 +283,19 @@
public void remove() {
assertNotComodified();
- if(-1 == _lastReturnedIndex) {
+ if (_lastReturnedIndex == -1) {
throw new IllegalStateException();
+ }
+ if (_lastReturnedIndex == _nextIndex) {
+ // remove() following previous()
+ getList().removeElementAt(_lastReturnedIndex);
} else {
+ // remove() following next()
getList().removeElementAt(_lastReturnedIndex);
- _lastReturnedIndex = -1;
_nextIndex--;
- resyncModCount();
}
+ _lastReturnedIndex = -1;
+ resyncModCount();
}
public void set(boolean value) {
Modified:
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessByteList.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessByteList.java?rev=224667&r1=224666&r2=224667&view=diff
==============================================================================
---
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessByteList.java
(original)
+++
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessByteList.java
Sun Jul 24 16:03:31 2005
@@ -283,14 +283,19 @@
public void remove() {
assertNotComodified();
- if(-1 == _lastReturnedIndex) {
+ if (_lastReturnedIndex == -1) {
throw new IllegalStateException();
+ }
+ if (_lastReturnedIndex == _nextIndex) {
+ // remove() following previous()
+ getList().removeElementAt(_lastReturnedIndex);
} else {
+ // remove() following next()
getList().removeElementAt(_lastReturnedIndex);
- _lastReturnedIndex = -1;
_nextIndex--;
- resyncModCount();
}
+ _lastReturnedIndex = -1;
+ resyncModCount();
}
public void set(byte value) {
Modified:
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessCharList.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessCharList.java?rev=224667&r1=224666&r2=224667&view=diff
==============================================================================
---
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessCharList.java
(original)
+++
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessCharList.java
Sun Jul 24 16:03:31 2005
@@ -275,14 +275,19 @@
public void remove() {
assertNotComodified();
- if(-1 == _lastReturnedIndex) {
+ if (_lastReturnedIndex == -1) {
throw new IllegalStateException();
+ }
+ if (_lastReturnedIndex == _nextIndex) {
+ // remove() following previous()
+ getList().removeElementAt(_lastReturnedIndex);
} else {
+ // remove() following next()
getList().removeElementAt(_lastReturnedIndex);
- _lastReturnedIndex = -1;
_nextIndex--;
- resyncModCount();
}
+ _lastReturnedIndex = -1;
+ resyncModCount();
}
public void set(char value) {
Modified:
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessDoubleList.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessDoubleList.java?rev=224667&r1=224666&r2=224667&view=diff
==============================================================================
---
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessDoubleList.java
(original)
+++
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessDoubleList.java
Sun Jul 24 16:03:31 2005
@@ -284,14 +284,19 @@
public void remove() {
assertNotComodified();
- if(-1 == _lastReturnedIndex) {
+ if (_lastReturnedIndex == -1) {
throw new IllegalStateException();
+ }
+ if (_lastReturnedIndex == _nextIndex) {
+ // remove() following previous()
+ getList().removeElementAt(_lastReturnedIndex);
} else {
+ // remove() following next()
getList().removeElementAt(_lastReturnedIndex);
- _lastReturnedIndex = -1;
_nextIndex--;
- resyncModCount();
}
+ _lastReturnedIndex = -1;
+ resyncModCount();
}
public void set(double value) {
Modified:
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessFloatList.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessFloatList.java?rev=224667&r1=224666&r2=224667&view=diff
==============================================================================
---
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessFloatList.java
(original)
+++
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessFloatList.java
Sun Jul 24 16:03:31 2005
@@ -283,14 +283,19 @@
public void remove() {
assertNotComodified();
- if(-1 == _lastReturnedIndex) {
+ if (_lastReturnedIndex == -1) {
throw new IllegalStateException();
+ }
+ if (_lastReturnedIndex == _nextIndex) {
+ // remove() following previous()
+ getList().removeElementAt(_lastReturnedIndex);
} else {
+ // remove() following next()
getList().removeElementAt(_lastReturnedIndex);
- _lastReturnedIndex = -1;
_nextIndex--;
- resyncModCount();
}
+ _lastReturnedIndex = -1;
+ resyncModCount();
}
public void set(float value) {
Modified:
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessIntList.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessIntList.java?rev=224667&r1=224666&r2=224667&view=diff
==============================================================================
---
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessIntList.java
(original)
+++
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessIntList.java
Sun Jul 24 16:03:31 2005
@@ -283,14 +283,19 @@
public void remove() {
assertNotComodified();
- if(-1 == _lastReturnedIndex) {
+ if (_lastReturnedIndex == -1) {
throw new IllegalStateException();
+ }
+ if (_lastReturnedIndex == _nextIndex) {
+ // remove() following previous()
+ getList().removeElementAt(_lastReturnedIndex);
} else {
+ // remove() following next()
getList().removeElementAt(_lastReturnedIndex);
- _lastReturnedIndex = -1;
_nextIndex--;
- resyncModCount();
}
+ _lastReturnedIndex = -1;
+ resyncModCount();
}
public void set(int value) {
Modified:
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessLongList.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessLongList.java?rev=224667&r1=224666&r2=224667&view=diff
==============================================================================
---
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessLongList.java
(original)
+++
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessLongList.java
Sun Jul 24 16:03:31 2005
@@ -284,14 +284,19 @@
public void remove() {
assertNotComodified();
- if(-1 == _lastReturnedIndex) {
+ if (_lastReturnedIndex == -1) {
throw new IllegalStateException();
+ }
+ if (_lastReturnedIndex == _nextIndex) {
+ // remove() following previous()
+ getList().removeElementAt(_lastReturnedIndex);
} else {
+ // remove() following next()
getList().removeElementAt(_lastReturnedIndex);
- _lastReturnedIndex = -1;
_nextIndex--;
- resyncModCount();
}
+ _lastReturnedIndex = -1;
+ resyncModCount();
}
public void set(long value) {
Modified:
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessShortList.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessShortList.java?rev=224667&r1=224666&r2=224667&view=diff
==============================================================================
---
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessShortList.java
(original)
+++
jakarta/commons/proper/primitives/trunk/src/java/org/apache/commons/collections/primitives/RandomAccessShortList.java
Sun Jul 24 16:03:31 2005
@@ -283,14 +283,19 @@
public void remove() {
assertNotComodified();
- if(-1 == _lastReturnedIndex) {
+ if (_lastReturnedIndex == -1) {
throw new IllegalStateException();
+ }
+ if (_lastReturnedIndex == _nextIndex) {
+ // remove() following previous()
+ getList().removeElementAt(_lastReturnedIndex);
} else {
+ // remove() following next()
getList().removeElementAt(_lastReturnedIndex);
- _lastReturnedIndex = -1;
_nextIndex--;
- resyncModCount();
}
+ _lastReturnedIndex = -1;
+ resyncModCount();
}
public void set(short value) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]