package o;

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

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

    public /* synthetic */ N(int i, Object obj) {
        this.l = i;
        this.n = obj;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        switch (this.l) {
            case 0:
                return this.m < ((Q) this.n).a();
            case 1:
                return this.m < ((Object[]) this.n).length;
            default:
                Iterator it = (Iterator) this.n;
                while (this.m > 0 && it.hasNext()) {
                    it.next();
                    this.m--;
                }
                return it.hasNext();
        }
    }

    @Override // java.util.Iterator
    public final Object next() {
        switch (this.l) {
            case 0:
                if (!hasNext()) {
                    throw new NoSuchElementException();
                }
                Q q = (Q) this.n;
                int i = this.m;
                this.m = i + 1;
                return q.get(i);
            case 1:
                try {
                    Object[] objArr = (Object[]) this.n;
                    int i2 = this.m;
                    this.m = i2 + 1;
                    return objArr[i2];
                } catch (ArrayIndexOutOfBoundsException e) {
                    this.m--;
                    throw new NoSuchElementException(e.getMessage());
                }
            default:
                Iterator it = (Iterator) this.n;
                while (this.m > 0 && it.hasNext()) {
                    it.next();
                    this.m--;
                }
                return it.next();
        }
    }

    @Override // java.util.Iterator
    public final void remove() {
        switch (this.l) {
            case 0:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
            case 1:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
            default:
                throw new UnsupportedOperationException("Operation is not supported for read-only collection");
        }
    }

    public N(C0123Et c0123Et) {
        this.l = 2;
        this.n = c0123Et.a.iterator();
        this.m = c0123Et.b;
    }
}
