/**
* An extensible iterator implementation.
*/
protected class EIterator<E1> implements Iterator<E1> {
/**
* The current position of the iterator.
*/
protected int cursor = 0;
/**
* The previous position of the iterator.
*/
protected int lastCursor = -1;
/**
* The modification count of the containing list.
*/
protected int expectedModCount = modCount;
/**
* Returns whether there are more objects.
* @return whether there are more objects.
*/
public boolean hasNext() {
return cursor != size();
}
/**
* Returns the next object and advances the iterator.
* This implementation delegates to {@link #doNext doNext}.
* @return the next object.
* @exception NoSuchElementException if the iterator is done.
*/
@SuppressWarnings("unchecked") public E1 next() {
return (E1) doNext();
}
/**
* Returns the next object and advances the iterator.
* This implementation delegates to {@link DelegatingEList#get get}.
* @return the next object.
* @exception NoSuchElementException if the iterator is done.
*/
/**
* Returns the next object and advances the iterator.
* This implementation delegates to {@link BasicEList#get get}.
* @return the next object.
* @exception NoSuchElementException if the iterator is done.
*/
protected E doNext() {
try {
E next = [[#variable19024480]].this.get(cursor);
checkModCount();
lastCursor = cursor++;
return next;
}
catch (IndexOutOfBoundsException
exception) {
checkModCount();
throw new NoSuchElementException();
}
}
/**
* Removes the last object returned by {@link #next()} from the list,
* it's an optional operation.
* This implementation can also function in a list iterator
* to act upon on the object returned by calling <code>previous</code>.
* @exception IllegalStateException
* if <code>next</code> has not yet been called,
* or <code>remove</code> has already been called after the last call to <code>next</code>.
*/
public void remove() {
if (lastCursor == -1) {
throw new IllegalStateException();
}
checkModCount();
try {
[[#variable19024480]].this.remove(lastCursor);
expectedModCount = modCount;
if (lastCursor < cursor) {
--cursor;
}
lastCursor = -1;
}
catch (IndexOutOfBoundsException
exception) {
throw new ConcurrentModificationException();
}
}
/**
* Checks that the modification count is as expected.
* @exception ConcurrentModificationException if the modification count is not as expected.
*/
protected void checkModCount() {
if (modCount != expectedModCount) {
throw new ConcurrentModificationException();
}
}
}
/**
* Returns a read-only iterator that does not {@link #resolve resolve} objects.
* This implementation allocates a {@link NonResolvingEIterator}.
* @return a read-only iterator that does not resolve objects.
*/
protected Iterator<E> basicIterator() {
return new NonResolvingEIterator<E>();
}
|