add AbstractList and AbstractSequentialList classes to java.util and listIterator methods to java.util.List

This commit is contained in:
Joel Dice
2009-08-04 17:24:29 -06:00
parent 93597a4d1d
commit 7911989055
9 changed files with 223 additions and 25 deletions

View File

@ -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();
}