package o;

import java.util.Iterator;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Q30 extends T30 implements Iterator {
    public R30 l;
    public R30 m;
    public final /* synthetic */ int n;

    public Q30(R30 r30, R30 r302, int i) {
        this.n = i;
        this.l = r302;
        this.m = r30;
    }

    @Override // o.T30
    public final void a(R30 r30) {
        R30 r302;
        R30 r30B = null;
        if (this.l == r30 && r30 == this.m) {
            this.m = null;
            this.l = null;
        }
        R30 r303 = this.l;
        if (r303 == r30) {
            switch (this.n) {
                case 0:
                    r302 = r303.f307o;
                    break;
                default:
                    r302 = r303.n;
                    break;
            }
            this.l = r302;
        }
        R30 r304 = this.m;
        if (r304 == r30) {
            R30 r305 = this.l;
            if (r304 != r305 && r305 != null) {
                r30B = b(r304);
            }
            this.m = r30B;
        }
    }

    public final R30 b(R30 r30) {
        switch (this.n) {
            case 0:
                return r30.n;
            default:
                return r30.f307o;
        }
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        return this.m != null;
    }

    @Override // java.util.Iterator
    public final Object next() {
        R30 r30 = this.m;
        R30 r302 = this.l;
        this.m = (r30 == r302 || r302 == null) ? null : b(r30);
        return r30;
    }
}
