package org.bouncycastle.asn1;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class ASN1EncodableVector {
    static final org.bouncycastle.asn1.ASN1Encodable[] d = new org.bouncycastle.asn1.ASN1Encodable[0];
    private org.bouncycastle.asn1.ASN1Encodable[] a;
    private int b;
    private boolean c;

    public ASN1EncodableVector() {
        this(10);
    }

    static org.bouncycastle.asn1.ASN1Encodable[] b(org.bouncycastle.asn1.ASN1Encodable[] aSN1EncodableArr) {
        return aSN1EncodableArr.length < 1 ? d : (org.bouncycastle.asn1.ASN1Encodable[]) aSN1EncodableArr.clone();
    }

    private void e(int i) {
        org.bouncycastle.asn1.ASN1Encodable[] aSN1EncodableArr = new org.bouncycastle.asn1.ASN1Encodable[java.lang.Math.max(this.a.length, i + (i >> 1))];
        java.lang.System.arraycopy(this.a, 0, aSN1EncodableArr, 0, this.b);
        this.a = aSN1EncodableArr;
        this.c = false;
    }

    public void a(org.bouncycastle.asn1.ASN1Encodable aSN1Encodable) {
        if (aSN1Encodable == null) {
            throw new java.lang.NullPointerException("'element' cannot be null");
        }
        int length = this.a.length;
        int i = this.b + 1;
        if (this.c | (i > length)) {
            e(i);
        }
        this.a[this.b] = aSN1Encodable;
        this.b = i;
    }

    org.bouncycastle.asn1.ASN1Encodable[] c() {
        int i = this.b;
        if (i == 0) {
            return d;
        }
        org.bouncycastle.asn1.ASN1Encodable[] aSN1EncodableArr = new org.bouncycastle.asn1.ASN1Encodable[i];
        java.lang.System.arraycopy(this.a, 0, aSN1EncodableArr, 0, i);
        return aSN1EncodableArr;
    }

    public org.bouncycastle.asn1.ASN1Encodable d(int i) {
        if (i < this.b) {
            return this.a[i];
        }
        throw new java.lang.ArrayIndexOutOfBoundsException(i + " >= " + this.b);
    }

    public int f() {
        return this.b;
    }

    org.bouncycastle.asn1.ASN1Encodable[] g() {
        int i = this.b;
        if (i == 0) {
            return d;
        }
        org.bouncycastle.asn1.ASN1Encodable[] aSN1EncodableArr = this.a;
        if (aSN1EncodableArr.length == i) {
            this.c = true;
            return aSN1EncodableArr;
        }
        org.bouncycastle.asn1.ASN1Encodable[] aSN1EncodableArr2 = new org.bouncycastle.asn1.ASN1Encodable[i];
        java.lang.System.arraycopy(aSN1EncodableArr, 0, aSN1EncodableArr2, 0, i);
        return aSN1EncodableArr2;
    }

    public ASN1EncodableVector(int i) {
        if (i < 0) {
            throw new java.lang.IllegalArgumentException("'initialCapacity' must not be negative");
        }
        this.a = i == 0 ? d : new org.bouncycastle.asn1.ASN1Encodable[i];
        this.b = 0;
        this.c = false;
    }
}
