@Override public E next () {
checkForComodification();
int ii = _cursor;
if (ii >= _size) throw new NoSuchElementException();
Object[] data = _data;
if (ii >= data.length) throw new ConcurrentModificationException();
_cursor = ii + 1;
@SuppressWarnings("unchecked") E elem = (E) data[_lastRet = ii];
return elem;
}
@Override public void remove () {
if (_lastRet < 0) throw new IllegalStateException();
checkForComodification();
try {
DestroyableList.this.remove(_lastRet);
_cursor = _lastRet;
_lastRet = -1;
_exModCount = _modCount;
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
}
}
final void checkForComodification() {
if (_modCount != _exModCount) throw new ConcurrentModificationException();
}
protected int _cursor; // index of next element to return
protected int _lastRet = -1; // index of last element returned; -1 if no such
protected int _exModCount = _modCount;