package i.b.a.j;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Iterator;
import java.util.concurrent.locks.ReentrantLock;

/* JADX INFO: compiled from: IdentityScopeObject.java */
/* JADX INFO: loaded from: classes.dex */
public class c<K, T> implements a<K, T> {
    private final HashMap<K, Reference<T>> a = new HashMap<>();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final ReentrantLock f4266b = new ReentrantLock();

    @Override // i.b.a.j.a
    public void a(K k2, T t) {
        this.a.put(k2, new WeakReference(t));
    }

    @Override // i.b.a.j.a
    public boolean b(K k2, T t) {
        boolean z;
        this.f4266b.lock();
        try {
            if (get(k2) != t || t == null) {
                z = false;
            } else {
                remove(k2);
                z = true;
            }
            return z;
        } finally {
            this.f4266b.unlock();
        }
    }

    @Override // i.b.a.j.a
    public void c(Iterable<K> iterable) {
        this.f4266b.lock();
        try {
            Iterator<K> it = iterable.iterator();
            while (it.hasNext()) {
                this.a.remove(it.next());
            }
        } finally {
            this.f4266b.unlock();
        }
    }

    @Override // i.b.a.j.a
    public void clear() {
        this.f4266b.lock();
        try {
            this.a.clear();
        } finally {
            this.f4266b.unlock();
        }
    }

    @Override // i.b.a.j.a
    public T d(K k2) {
        Reference<T> reference = this.a.get(k2);
        if (reference != null) {
            return reference.get();
        }
        return null;
    }

    @Override // i.b.a.j.a
    public void e(int i2) {
    }

    @Override // i.b.a.j.a
    public T get(K k2) {
        this.f4266b.lock();
        try {
            Reference<T> reference = this.a.get(k2);
            if (reference != null) {
                return reference.get();
            }
            return null;
        } finally {
            this.f4266b.unlock();
        }
    }

    @Override // i.b.a.j.a
    public void lock() {
        this.f4266b.lock();
    }

    @Override // i.b.a.j.a
    public void put(K k2, T t) {
        this.f4266b.lock();
        try {
            this.a.put(k2, new WeakReference(t));
        } finally {
            this.f4266b.unlock();
        }
    }

    @Override // i.b.a.j.a
    public void remove(K k2) {
        this.f4266b.lock();
        try {
            this.a.remove(k2);
        } finally {
            this.f4266b.unlock();
        }
    }

    @Override // i.b.a.j.a
    public void unlock() {
        this.f4266b.unlock();
    }
}
