package ῲ.㴹;

import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;

/* renamed from: ῲ.㴹.㴹  reason: contains not printable characters */
/* compiled from: LruCache */
public class C2286<K, V> {

    /* renamed from: ʬ  reason: contains not printable characters */
    public int f7893;

    /* renamed from: ඓ  reason: contains not printable characters */
    public int f7894;

    /* renamed from: ῲ  reason: contains not printable characters */
    public int f7895;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public int f7896;

    /* renamed from: K  reason: contains not printable characters */
    public final LinkedHashMap<K, V> f7897;

    /* renamed from: 㴹  reason: contains not printable characters */
    public int f7898;

    /* renamed from: 㸾  reason: contains not printable characters */
    public int f7899;

    public C2286(int i) {
        if (i > 0) {
            this.f7893 = i;
            this.f7897 = new LinkedHashMap<>(0, 0.75f, true);
            return;
        }
        throw new IllegalArgumentException("maxSize <= 0");
    }

    public final synchronized String toString() {
        int i;
        i = this.f7898 + this.f7896;
        return String.format(Locale.US, "LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]", Integer.valueOf(this.f7893), Integer.valueOf(this.f7898), Integer.valueOf(this.f7896), Integer.valueOf(i != 0 ? (this.f7898 * 100) / i : 0));
    }

    /* renamed from: K  reason: contains not printable characters */
    public final V m5962(K k) {
        if (k != null) {
            synchronized (this) {
                V v = this.f7897.get(k);
                if (v != null) {
                    this.f7898++;
                    return v;
                }
                this.f7896++;
                return null;
            }
        }
        throw new NullPointerException("key == null");
    }

    /* renamed from: K  reason: contains not printable characters */
    public final V m5963(K k, V v) {
        V put;
        if (k == null || v == null) {
            throw new NullPointerException("key == null || value == null");
        }
        synchronized (this) {
            this.f7899++;
            this.f7895++;
            put = this.f7897.put(k, v);
            if (put != null) {
                this.f7895--;
            }
        }
        m5964(this.f7893);
        return put;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0068, code lost:
        throw new java.lang.IllegalStateException(getClass().getName() + ".sizeOf() is reporting inconsistent results!");
     */
    /* renamed from: K  reason: contains not printable characters */
    public void m5964(int i) {
        while (true) {
            synchronized (this) {
                if (this.f7895 < 0 || (this.f7897.isEmpty() && this.f7895 != 0)) {
                } else if (this.f7895 <= i) {
                    break;
                } else if (this.f7897.isEmpty()) {
                    break;
                } else {
                    Map.Entry<K, V> next = this.f7897.entrySet().iterator().next();
                    K key = next.getKey();
                    next.getValue();
                    this.f7897.remove(key);
                    this.f7895--;
                    this.f7894++;
                }
            }
        }
    }
}
