package sm;

import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public abstract class y0 extends x0 {
    public static Set i(Set set, Iterable elements) {
        kotlin.jvm.internal.t.g(set, "<this>");
        kotlin.jvm.internal.t.g(elements, "elements");
        Collection<?> C = z.C(elements);
        if (C.isEmpty()) {
            return s.X0(set);
        }
        if (!(C instanceof Set)) {
            LinkedHashSet linkedHashSet = new LinkedHashSet(set);
            linkedHashSet.removeAll(C);
            return linkedHashSet;
        }
        LinkedHashSet linkedHashSet2 = new LinkedHashSet();
        for (Object obj : set) {
            if (!C.contains(obj)) {
                linkedHashSet2.add(obj);
            }
        }
        return linkedHashSet2;
    }

    public static Set j(Set set, Object obj) {
        kotlin.jvm.internal.t.g(set, "<this>");
        LinkedHashSet linkedHashSet = new LinkedHashSet(n0.d(set.size()));
        boolean z10 = false;
        for (Object obj2 : set) {
            boolean z11 = true;
            if (!z10 && kotlin.jvm.internal.t.b(obj2, obj)) {
                z10 = true;
                z11 = false;
            }
            if (z11) {
                linkedHashSet.add(obj2);
            }
        }
        return linkedHashSet;
    }

    public static Set k(Set set, Iterable elements) {
        int size;
        kotlin.jvm.internal.t.g(set, "<this>");
        kotlin.jvm.internal.t.g(elements, "elements");
        Integer w10 = v.w(elements);
        if (w10 != null) {
            size = set.size() + w10.intValue();
        } else {
            size = set.size() * 2;
        }
        LinkedHashSet linkedHashSet = new LinkedHashSet(n0.d(size));
        linkedHashSet.addAll(set);
        s.A(linkedHashSet, elements);
        return linkedHashSet;
    }

    public static Set l(Set set, Object obj) {
        kotlin.jvm.internal.t.g(set, "<this>");
        LinkedHashSet linkedHashSet = new LinkedHashSet(n0.d(set.size() + 1));
        linkedHashSet.addAll(set);
        linkedHashSet.add(obj);
        return linkedHashSet;
    }
}
