package androidx.collection;

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

/* loaded from: classes.dex */
public abstract class h implements Iterator, en.a {

    /* renamed from: p, reason: collision with root package name */
    private int f1301p;

    /* renamed from: q, reason: collision with root package name */
    private int f1302q;

    /* renamed from: r, reason: collision with root package name */
    private boolean f1303r;

    public h(int i10) {
        this.f1301p = i10;
    }

    protected abstract Object a(int i10);

    protected abstract void b(int i10);

    @Override // java.util.Iterator
    public boolean hasNext() {
        return this.f1302q < this.f1301p;
    }

    @Override // java.util.Iterator
    public Object next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        Object a10 = a(this.f1302q);
        this.f1302q++;
        this.f1303r = true;
        return a10;
    }

    @Override // java.util.Iterator
    public void remove() {
        if (!this.f1303r) {
            w.d.b("Call next() before removing an element.");
        }
        int i10 = this.f1302q - 1;
        this.f1302q = i10;
        b(i10);
        this.f1301p--;
        this.f1303r = false;
    }
}
