package F3;

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

/* JADX INFO: loaded from: classes3.dex */
public abstract class I {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public Object[] f1499a;

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

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

    public I(int i6) {
        AbstractC0220u.d(i6, "initialCapacity");
        this.f1499a = new Object[i6];
        this.f1500b = 0;
    }

    public static int d(int i6, int i7) {
        if (i7 < 0) {
            throw new AssertionError("cannot store more than MAX_VALUE elements");
        }
        int iHighestOneBit = i6 + (i6 >> 1) + 1;
        if (iHighestOneBit < i7) {
            iHighestOneBit = Integer.highestOneBit(i7 - 1) << 1;
        }
        if (iHighestOneBit < 0) {
            return Integer.MAX_VALUE;
        }
        return iHighestOneBit;
    }

    public final void a(Object obj) {
        obj.getClass();
        e(this.f1500b + 1);
        Object[] objArr = this.f1499a;
        int i6 = this.f1500b;
        this.f1500b = i6 + 1;
        objArr[i6] = obj;
    }

    public abstract I b(Object obj);

    public final void c(Iterable iterable) {
        if (iterable instanceof Collection) {
            Collection collection = (Collection) iterable;
            e(collection.size() + this.f1500b);
            if (collection instanceof J) {
                this.f1500b = ((J) collection).g(this.f1500b, this.f1499a);
                return;
            }
        }
        Iterator it = iterable.iterator();
        while (it.hasNext()) {
            b(it.next());
        }
    }

    public final void e(int i6) {
        Object[] objArr = this.f1499a;
        if (objArr.length < i6) {
            this.f1499a = Arrays.copyOf(objArr, d(objArr.length, i6));
            this.f1501c = false;
        } else if (this.f1501c) {
            this.f1499a = (Object[]) objArr.clone();
            this.f1501c = false;
        }
    }
}
