package o;

import java.util.Iterator;
import java.util.NoSuchElementException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class U20 implements Iterator, InterfaceC2989yJ {
    public int l;
    public Object m;
    public int n;

    /* renamed from: o, reason: collision with root package name */
    public int f350o;
    public final /* synthetic */ V20 p;

    public U20(V20 v20) {
        this.p = v20;
        this.n = v20.f367o;
        this.f350o = v20.n;
    }

    public final boolean a() {
        this.l = 3;
        int i = this.n;
        if (i == 0) {
            this.l = 2;
        } else {
            V20 v20 = this.p;
            Object[] objArr = v20.l;
            int i2 = this.f350o;
            this.m = objArr[i2];
            this.l = 1;
            this.f350o = (i2 + 1) % v20.m;
            this.n = i - 1;
        }
        return this.l == 1;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        int i = this.l;
        if (i == 0) {
            return a();
        }
        if (i == 1) {
            return true;
        }
        if (i == 2) {
            return false;
        }
        throw new IllegalArgumentException("hasNext called when the iterator is in the FAILED state.");
    }

    @Override // java.util.Iterator
    public final Object next() {
        int i = this.l;
        if (i == 1) {
            this.l = 0;
            return this.m;
        }
        if (i == 2 || !a()) {
            throw new NoSuchElementException();
        }
        this.l = 0;
        return this.m;
    }

    @Override // java.util.Iterator
    public final void remove() {
        throw new UnsupportedOperationException("Operation is not supported for read-only collection");
    }
}
