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

35 lines
866 B
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
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;
}
}