package o;

import java.util.NoSuchElementException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Zg0 extends S {
    public int n;

    /* renamed from: o, reason: collision with root package name */
    public Object[] f439o;
    public boolean p;

    /* JADX WARN: Type inference failed for: r5v1 */
    /* JADX WARN: Type inference failed for: r5v2, types: [boolean, int] */
    /* JADX WARN: Type inference failed for: r5v3 */
    public Zg0(Object[] objArr, int i, int i2, int i3) {
        super(i, i2);
        this.n = i3;
        Object[] objArr2 = new Object[i3];
        this.f439o = objArr2;
        ?? r5 = i == i2 ? 1 : 0;
        this.p = r5;
        objArr2[0] = objArr;
        b(i - r5, 1);
    }

    public final Object a() {
        return ((Object[]) this.f439o[this.n - 1])[this.l & 31];
    }

    public final void b(int i, int i2) {
        int i3 = (this.n - i2) * 5;
        while (i2 < this.n) {
            Object[] objArr = this.f439o;
            objArr[i2] = ((Object[]) objArr[i2 - 1])[F3.D(i, i3)];
            i3 -= 5;
            i2++;
        }
    }

    public final void c(int i) {
        int i2 = 0;
        while (F3.D(this.l, i2) == i) {
            i2 += 5;
        }
        if (i2 > 0) {
            b(this.l, ((this.n - 1) - (i2 / 5)) + 1);
        }
    }

    @Override // java.util.ListIterator, java.util.Iterator
    public final Object next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        Object objA = a();
        int i = this.l + 1;
        this.l = i;
        if (i == this.m) {
            this.p = true;
            return objA;
        }
        c(0);
        return objA;
    }

    @Override // java.util.ListIterator
    public final Object previous() {
        if (!hasPrevious()) {
            throw new NoSuchElementException();
        }
        this.l--;
        if (this.p) {
            this.p = false;
            return a();
        }
        c(31);
        return a();
    }
}
