mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-15 02:17:18 +01:00
71 lines
1.9 KiB
Java
71 lines
1.9 KiB
Java
package com.google.common.base;
|
|
|
|
import com.google.common.annotations.GwtCompatible;
|
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
|
import java.util.Iterator;
|
|
import rx.Single$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@GwtCompatible
|
|
/* loaded from: classes8.dex */
|
|
abstract class AbstractIterator<T> implements Iterator<T> {
|
|
private T next;
|
|
private State state = State.NOT_READY;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum State {
|
|
READY,
|
|
NOT_READY,
|
|
DONE,
|
|
FAILED
|
|
}
|
|
|
|
private boolean tryToComputeNext() {
|
|
this.state = State.FAILED;
|
|
this.next = computeNext();
|
|
if (this.state == State.DONE) {
|
|
return false;
|
|
}
|
|
this.state = State.READY;
|
|
return true;
|
|
}
|
|
|
|
public abstract T computeNext();
|
|
|
|
@CanIgnoreReturnValue
|
|
public final T endOfData() {
|
|
this.state = State.DONE;
|
|
return null;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public final boolean hasNext() {
|
|
Preconditions.checkState(this.state != State.FAILED);
|
|
int ordinal = this.state.ordinal();
|
|
if (ordinal == 0) {
|
|
return true;
|
|
}
|
|
if (ordinal != 2) {
|
|
return tryToComputeNext();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
@ParametricNullness
|
|
public final T next() {
|
|
if (!hasNext()) {
|
|
Single$$ExternalSyntheticBUOutline0.m();
|
|
return null;
|
|
}
|
|
this.state = State.NOT_READY;
|
|
T t = (T) NullnessCasts.uncheckedCastNullableTToT(this.next);
|
|
this.next = null;
|
|
return t;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public final void remove() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|