package g2;

import java.util.Objects;

/* JADX INFO: compiled from: ASN1EncodableVector.java */
/* JADX INFO: loaded from: classes.dex */
public class e {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    static final d[] f4690d = new d[0];

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private d[] f4691a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private boolean f4693c;

    public e() {
        this(10);
    }

    static d[] b(d[] dVarArr) {
        return dVarArr.length < 1 ? f4690d : (d[]) dVarArr.clone();
    }

    private void e(int i3) {
        d[] dVarArr = new d[Math.max(this.f4691a.length, i3 + (i3 >> 1))];
        System.arraycopy(this.f4691a, 0, dVarArr, 0, this.f4692b);
        this.f4691a = dVarArr;
        this.f4693c = false;
    }

    public void a(d dVar) {
        Objects.requireNonNull(dVar, "'element' cannot be null");
        int length = this.f4691a.length;
        int i3 = this.f4692b + 1;
        if (this.f4693c | (i3 > length)) {
            e(i3);
        }
        this.f4691a[this.f4692b] = dVar;
        this.f4692b = i3;
    }

    d[] c() {
        int i3 = this.f4692b;
        if (i3 == 0) {
            return f4690d;
        }
        d[] dVarArr = new d[i3];
        System.arraycopy(this.f4691a, 0, dVarArr, 0, i3);
        return dVarArr;
    }

    public d d(int i3) {
        if (i3 < this.f4692b) {
            return this.f4691a[i3];
        }
        throw new ArrayIndexOutOfBoundsException(i3 + " >= " + this.f4692b);
    }

    public int f() {
        return this.f4692b;
    }

    d[] g() {
        int i3 = this.f4692b;
        if (i3 == 0) {
            return f4690d;
        }
        d[] dVarArr = this.f4691a;
        if (dVarArr.length == i3) {
            this.f4693c = true;
            return dVarArr;
        }
        d[] dVarArr2 = new d[i3];
        System.arraycopy(dVarArr, 0, dVarArr2, 0, i3);
        return dVarArr2;
    }

    public e(int i3) {
        if (i3 < 0) {
            throw new IllegalArgumentException("'initialCapacity' must not be negative");
        }
        this.f4691a = i3 == 0 ? f4690d : new d[i3];
        this.f4692b = 0;
        this.f4693c = false;
    }
}
