package androidx.datastore.preferences.protobuf;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import n4.u0;
import q.C1442c;

/* JADX INFO: loaded from: classes.dex */
public class Z extends AbstractSet {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f8050q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ Map f8051r;

    public /* synthetic */ Z(Map map, int i) {
        this.f8050q = i;
        this.f8051r = map;
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
    public boolean add(Object obj) {
        switch (this.f8050q) {
            case u0.f15495q /* 0 */:
                Map.Entry entry = (Map.Entry) obj;
                if (contains(entry)) {
                    return false;
                }
                ((W) this.f8051r).put((Comparable) entry.getKey(), entry.getValue());
                return true;
            default:
                return super.add(obj);
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
    public void clear() {
        switch (this.f8050q) {
            case u0.f15495q /* 0 */:
                ((W) this.f8051r).clear();
                break;
            default:
                super.clear();
                break;
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
    public boolean contains(Object obj) {
        switch (this.f8050q) {
            case u0.f15495q /* 0 */:
                Map.Entry entry = (Map.Entry) obj;
                Object obj2 = ((W) this.f8051r).get(entry.getKey());
                Object value = entry.getValue();
                return obj2 == value || (obj2 != null && obj2.equals(value));
            default:
                return super.contains(obj);
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
    public Iterator iterator() {
        switch (this.f8050q) {
            case u0.f15495q /* 0 */:
                return new Y((W) this.f8051r);
            default:
                return new C1442c((q.e) this.f8051r);
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
    public boolean remove(Object obj) {
        switch (this.f8050q) {
            case u0.f15495q /* 0 */:
                Map.Entry entry = (Map.Entry) obj;
                if (!contains(entry)) {
                    return false;
                }
                ((W) this.f8051r).remove(entry.getKey());
                return true;
            default:
                return super.remove(obj);
        }
    }

    @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
    public final int size() {
        switch (this.f8050q) {
            case u0.f15495q /* 0 */:
                return ((W) this.f8051r).size();
            default:
                return ((q.e) this.f8051r).f16190s;
        }
    }
}
