package com.google.android.gms.internal.ads;

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

/* JADX INFO: loaded from: classes2.dex */
public abstract class tr1 implements Iterator {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f16994a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f16995b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f16996c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ zzgtm f16997d;

    public tr1(zzgtm zzgtmVar) {
        this.f16997d = zzgtmVar;
        this.f16994a = zzgtmVar.f19762e;
        this.f16995b = zzgtmVar.isEmpty() ? -1 : 0;
        this.f16996c = -1;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        return this.f16995b >= 0;
    }

    @Override // java.util.Iterator
    public final Object next() {
        Object ur1Var;
        zzgtm zzgtmVar = this.f16997d;
        if (zzgtmVar.f19762e != this.f16994a) {
            throw new ConcurrentModificationException();
        }
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        int i10 = this.f16995b;
        this.f16996c = i10;
        rr1 rr1Var = (rr1) this;
        int i11 = rr1Var.f16207e;
        zzgtm zzgtmVar2 = rr1Var.f16208f;
        switch (i11) {
            case 0:
                ur1Var = zzgtmVar2.b()[i10];
                break;
            case 1:
                ur1Var = new ur1(zzgtmVar2, i10);
                break;
            default:
                ur1Var = zzgtmVar2.d()[i10];
                break;
        }
        int i12 = this.f16995b + 1;
        if (i12 >= zzgtmVar.f19763f) {
            i12 = -1;
        }
        this.f16995b = i12;
        return ur1Var;
    }

    @Override // java.util.Iterator
    public final void remove() {
        zzgtm zzgtmVar = this.f16997d;
        if (zzgtmVar.f19762e != this.f16994a) {
            throw new ConcurrentModificationException();
        }
        ih1.f1("no calls to next() since the last call to remove()", this.f16996c >= 0);
        this.f16994a += 32;
        zzgtmVar.remove(zzgtmVar.b()[this.f16996c]);
        this.f16995b--;
        this.f16996c = -1;
    }
}
