package mp;

import java.util.Arrays;
import java.util.Iterator;

/* loaded from: classes3.dex */
public final class d extends c {

    /* renamed from: r, reason: collision with root package name */
    public static final a f29570r = new a(null);

    /* renamed from: p, reason: collision with root package name */
    private Object[] f29571p;

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

    /* loaded from: classes3.dex */
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(kotlin.jvm.internal.k kVar) {
            this();
        }
    }

    /* loaded from: classes3.dex */
    public static final class b extends sm.b {

        /* renamed from: r, reason: collision with root package name */
        private int f29573r = -1;

        b() {
        }

        @Override // sm.b
        protected void a() {
            do {
                int i10 = this.f29573r + 1;
                this.f29573r = i10;
                if (i10 >= d.this.f29571p.length) {
                    break;
                }
            } while (d.this.f29571p[this.f29573r] == null);
            if (this.f29573r >= d.this.f29571p.length) {
                b();
                return;
            }
            Object obj = d.this.f29571p[this.f29573r];
            kotlin.jvm.internal.t.e(obj, "null cannot be cast to non-null type T of org.jetbrains.kotlin.util.ArrayMapImpl");
            c(obj);
        }
    }

    private d(Object[] objArr, int i10) {
        super(null);
        this.f29571p = objArr;
        this.f29572q = i10;
    }

    private final void m(int i10) {
        Object[] objArr = this.f29571p;
        if (objArr.length > i10) {
            return;
        }
        int length = objArr.length;
        do {
            length *= 2;
        } while (length <= i10);
        Object[] copyOf = Arrays.copyOf(this.f29571p, length);
        kotlin.jvm.internal.t.f(copyOf, "copyOf(...)");
        this.f29571p = copyOf;
    }

    @Override // mp.c
    public int e() {
        return this.f29572q;
    }

    @Override // mp.c
    public void g(int i10, Object value) {
        kotlin.jvm.internal.t.g(value, "value");
        m(i10);
        if (this.f29571p[i10] == null) {
            this.f29572q = e() + 1;
        }
        this.f29571p[i10] = value;
    }

    @Override // mp.c
    public Object get(int i10) {
        Object c02;
        c02 = sm.p.c0(this.f29571p, i10);
        return c02;
    }

    @Override // mp.c, java.lang.Iterable
    public Iterator iterator() {
        return new b();
    }

    public d() {
        this(new Object[20], 0);
    }
}
