what-the-bank/sources/com/google/common/collect/AbstractIndexedListIterator...

66 lines
1.7 KiB
Java

package com.google.common.collect;
import com.google.common.base.Preconditions;
import java.util.NoSuchElementException;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public abstract class AbstractIndexedListIterator<E> extends UnmodifiableListIterator<E> {
private int position;
private final int size;
protected abstract E get(int i);
/* JADX INFO: Access modifiers changed from: protected */
public AbstractIndexedListIterator(int i) {
this(i, 0);
}
/* JADX INFO: Access modifiers changed from: protected */
public AbstractIndexedListIterator(int i, int i2) {
Preconditions.checkPositionIndex(i2, i);
this.size = i;
this.position = i2;
}
@Override // java.util.Iterator, java.util.ListIterator
public final E next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
int i = this.position;
this.position = i + 1;
return get(i);
}
@Override // java.util.ListIterator
public final E previous() {
if (!hasPrevious()) {
throw new NoSuchElementException();
}
int i = this.position - 1;
this.position = i;
return get(i);
}
@Override // java.util.ListIterator
public final int previousIndex() {
return this.position - 1;
}
@Override // java.util.ListIterator
public final int nextIndex() {
return this.position;
}
@Override // java.util.ListIterator
public final boolean hasPrevious() {
return this.position > 0;
}
@Override // java.util.Iterator, java.util.ListIterator
public final boolean hasNext() {
return this.position < this.size;
}
}