package com.google.common.collect;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

/* JADX INFO: loaded from: classes2.dex */
public class v0 extends k0 {

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

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

    @Override // com.google.common.collect.l0
    public /* bridge */ /* synthetic */ l0 a(Object obj) {
        i(obj);
        return this;
    }

    public v0 i(Object obj) {
        obj.getClass();
        if (this.f23735d != null) {
            int iL = ImmutableSet.l(this.f23688b);
            Object[] objArr = this.f23735d;
            if (iL <= objArr.length) {
                int length = objArr.length - 1;
                int iHashCode = obj.hashCode();
                int iW = z0.w(iHashCode);
                while (true) {
                    int i10 = iW & length;
                    Object[] objArr2 = this.f23735d;
                    Object obj2 = objArr2[i10];
                    if (obj2 == null) {
                        objArr2[i10] = obj;
                        this.f23736e += iHashCode;
                        c(obj);
                        break;
                    }
                    if (obj2.equals(obj)) {
                        break;
                    }
                    iW = i10 + 1;
                }
                return this;
            }
        }
        this.f23735d = null;
        c(obj);
        return this;
    }

    public v0 j(Object... objArr) {
        if (this.f23735d != null) {
            for (Object obj : objArr) {
                i(obj);
            }
        } else {
            d(objArr);
        }
        return this;
    }

    public v0 k(Iterable iterable) {
        iterable.getClass();
        if (this.f23735d != null) {
            Iterator it = iterable.iterator();
            while (it.hasNext()) {
                i(it.next());
            }
        } else {
            f((List) iterable);
        }
        return this;
    }

    public ImmutableSet l() {
        ImmutableSet immutableSetM;
        int i10 = this.f23688b;
        if (i10 == 0) {
            int i11 = ImmutableSet.f23608c;
            return RegularImmutableSet.f23632j;
        }
        if (i10 == 1) {
            Object obj = this.f23687a[0];
            Objects.requireNonNull(obj);
            int i12 = ImmutableSet.f23608c;
            return new SingletonImmutableSet(obj);
        }
        if (this.f23735d == null || ImmutableSet.l(i10) != this.f23735d.length) {
            immutableSetM = ImmutableSet.m(this.f23688b, this.f23687a);
            this.f23688b = immutableSetM.size();
        } else {
            int i13 = this.f23688b;
            Object[] objArrCopyOf = this.f23687a;
            int length = objArrCopyOf.length;
            if (i13 < (length >> 1) + (length >> 2)) {
                objArrCopyOf = Arrays.copyOf(objArrCopyOf, i13);
            }
            immutableSetM = new RegularImmutableSet(objArrCopyOf, this.f23736e, this.f23735d, r6.length - 1, this.f23688b);
        }
        this.f23689c = true;
        this.f23735d = null;
        return immutableSetM;
    }
}
