35 lines
866 B
Java
35 lines
866 B
Java
package com.google.common.collect;
|
|
|
|
import java.util.NoSuchElementException;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public abstract class AbstractSequentialIterator<T> extends UnmodifiableIterator<T> {
|
|
private T nextOrNull;
|
|
|
|
protected abstract T computeNext(T t);
|
|
|
|
public AbstractSequentialIterator(T t) {
|
|
this.nextOrNull = t;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public final T next() {
|
|
if (!hasNext()) {
|
|
throw new NoSuchElementException();
|
|
}
|
|
try {
|
|
T t = this.nextOrNull;
|
|
this.nextOrNull = computeNext(t);
|
|
return t;
|
|
} catch (Throwable th) {
|
|
this.nextOrNull = computeNext(this.nextOrNull);
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public final boolean hasNext() {
|
|
return this.nextOrNull != null;
|
|
}
|
|
}
|