package defpackage;

import java.lang.ref.WeakReference;
import java.util.AbstractMap;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/* JADX INFO: renamed from: ˑᵥˁ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C2110 implements Set {

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public static final AtomicLong f8400 = new AtomicLong();

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final long f8401;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final AbstractMap f8402;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final ReentrantReadWriteLock f8403;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public C2283 f8404;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final /* synthetic */ int f8405;

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C2110() {
        this(new HashMap(), (byte) 0);
        this.f8405 = 0;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ C2110(AbstractMap abstractMap) {
        this(abstractMap, (byte) 0);
        this.f8405 = 1;
    }

    public C2110(AbstractMap abstractMap, byte b) {
        this.f8401 = f8400.getAndIncrement();
        this.f8403 = new ReentrantReadWriteLock();
        this.f8402 = abstractMap;
    }

    @Override // java.util.Set, java.util.Collection
    public final boolean add(Object obj) {
        boolean z = false;
        if (obj == null) {
            return false;
        }
        ReentrantReadWriteLock.WriteLock writeLock = this.f8403.writeLock();
        try {
            writeLock.lock();
            AbstractMap abstractMap = this.f8402;
            if (!abstractMap.containsKey(obj)) {
                C2283 c2283M5619 = m5619(obj, this.f8404);
                this.f8404 = c2283M5619;
                abstractMap.put(obj, c2283M5619);
                z = true;
            }
            return z;
        } finally {
            writeLock.unlock();
        }
    }

    @Override // java.util.Set, java.util.Collection
    public final boolean addAll(Collection collection) {
        boolean z;
        ReentrantReadWriteLock.WriteLock writeLock = this.f8403.writeLock();
        try {
            writeLock.lock();
            boolean z2 = false;
            for (Object obj : collection) {
                if (obj != null) {
                    AbstractMap abstractMap = this.f8402;
                    if (abstractMap.containsKey(obj)) {
                        z = false;
                    } else {
                        C2283 c2283M5619 = m5619(obj, this.f8404);
                        this.f8404 = c2283M5619;
                        abstractMap.put(obj, c2283M5619);
                        z = true;
                    }
                    z2 |= z;
                }
            }
            return z2;
        } finally {
            writeLock.unlock();
        }
    }

    @Override // java.util.Set, java.util.Collection
    public final void clear() {
        ReentrantReadWriteLock.WriteLock writeLock = this.f8403.writeLock();
        try {
            writeLock.lock();
            this.f8404 = null;
            this.f8402.clear();
        } finally {
            writeLock.unlock();
        }
    }

    @Override // java.util.Set, java.util.Collection
    public final boolean contains(Object obj) {
        ReentrantReadWriteLock.ReadLock lock = this.f8403.readLock();
        try {
            lock.lock();
            C2283 c2283 = (C2283) this.f8402.get(obj);
            return (c2283 == null || c2283.m5895() == null) ? false : true;
        } finally {
            lock.unlock();
        }
    }

    @Override // java.util.Set, java.util.Collection
    public final boolean containsAll(Collection collection) {
        throw new UnsupportedOperationException("Not implemented");
    }

    @Override // java.util.Set, java.util.Collection
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        return obj != null && getClass() == obj.getClass() && this.f8401 == ((C2110) obj).f8401;
    }

    @Override // java.util.Set, java.util.Collection
    public final int hashCode() {
        long j = this.f8401;
        return 31 + ((int) (j ^ (j >>> 32)));
    }

    @Override // java.util.Set, java.util.Collection
    public final boolean isEmpty() {
        return this.f8404 == null;
    }

    @Override // java.util.Set, java.util.Collection, java.lang.Iterable
    public final Iterator iterator() {
        switch (this.f8405) {
            case 0:
                return new C3700(this);
            default:
                return new C3700(this, (byte) 0);
        }
    }

    @Override // java.util.Set, java.util.Collection
    public final boolean remove(Object obj) {
        AbstractMap abstractMap = this.f8402;
        if (!contains(obj)) {
            return false;
        }
        ReentrantReadWriteLock.WriteLock writeLock = this.f8403.writeLock();
        try {
            writeLock.lock();
            C2283 c2283 = (C2283) abstractMap.get(obj);
            if (c2283 == null) {
                return false;
            }
            C2283 c22832 = this.f8404;
            if (c2283 != c22832) {
                C2283 c22833 = c2283.f8982;
                C2283 c22834 = c2283.f8984;
                if (c22833 != null) {
                    c22833.f8984 = c22834;
                    C2283 c22835 = c2283.f8984;
                    if (c22835 != null) {
                        c22835.f8982 = c22833;
                    }
                } else if (c22834 != null) {
                    c22834.f8982 = null;
                }
            } else {
                this.f8404 = c22832.f8984;
            }
            abstractMap.remove(obj);
            writeLock.unlock();
            return true;
        } finally {
            writeLock.unlock();
        }
    }

    @Override // java.util.Set, java.util.Collection
    public final boolean removeAll(Collection collection) {
        throw new UnsupportedOperationException("Not implemented");
    }

    @Override // java.util.Set, java.util.Collection
    public final boolean retainAll(Collection collection) {
        throw new UnsupportedOperationException("Not implemented");
    }

    @Override // java.util.Set, java.util.Collection
    public final int size() {
        return this.f8402.size();
    }

    @Override // java.util.Set, java.util.Collection
    public final Object[] toArray() {
        return this.f8402.entrySet().toArray();
    }

    @Override // java.util.Set, java.util.Collection
    public final Object[] toArray(Object[] objArr) {
        return this.f8402.entrySet().toArray(objArr);
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final C2283 m5619(Object obj, C2283 c2283) {
        C2283 c22832;
        C2283 c22833;
        switch (this.f8405) {
            case 0:
                if (c2283 != null) {
                    c22832 = new C2283(c2283, 0);
                    c22832.f8985 = obj;
                } else {
                    c22832 = new C2283(0);
                    c22832.f8985 = obj;
                }
                return c22832;
            default:
                if (c2283 != null) {
                    c22833 = new C2283(c2283, 1);
                    c22833.f8985 = new WeakReference(obj);
                } else {
                    c22833 = new C2283(1);
                    c22833.f8985 = new WeakReference(obj);
                }
                return c22833;
        }
    }
}
