mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
add AbstractList and AbstractSequentialList classes to java.util and listIterator methods to java.util.List
This commit is contained in:
@ -198,7 +198,6 @@ public class Collections {
|
||||
return new SynchronizedMap<K, V> (map);
|
||||
}
|
||||
|
||||
|
||||
static class SynchronizedSet<T>
|
||||
extends SynchronizedCollection<T>
|
||||
implements Set<T>
|
||||
@ -232,7 +231,7 @@ public class Collections {
|
||||
|
||||
static class ArrayListIterator<T> implements ListIterator<T> {
|
||||
private final List<T> list;
|
||||
private boolean canRemove = false;
|
||||
private int toRemove = -1;
|
||||
private int index;
|
||||
|
||||
public ArrayListIterator(List<T> list) {
|
||||
@ -250,7 +249,7 @@ public class Collections {
|
||||
|
||||
public T previous() {
|
||||
if (hasPrevious()) {
|
||||
canRemove = true;
|
||||
toRemove = index;
|
||||
return list.get(index--);
|
||||
} else {
|
||||
throw new NoSuchElementException();
|
||||
@ -259,8 +258,8 @@ public class Collections {
|
||||
|
||||
public T next() {
|
||||
if (hasNext()) {
|
||||
canRemove = true;
|
||||
return list.get(++index);
|
||||
toRemove = ++index;
|
||||
return list.get(index);
|
||||
} else {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
@ -271,9 +270,10 @@ public class Collections {
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
if (canRemove) {
|
||||
canRemove = false;
|
||||
list.remove(index--);
|
||||
if (toRemove != -1) {
|
||||
list.remove(toRemove);
|
||||
index = toRemove - 1;
|
||||
toRemove = -1;
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
Reference in New Issue
Block a user