package b7; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; /* loaded from: classes2.dex */ public class g { /* renamed from: a, reason: collision with root package name */ private final Map f3319a = new LinkedHashMap(100, 0.75f, true); /* renamed from: b, reason: collision with root package name */ private final long f3320b; /* renamed from: c, reason: collision with root package name */ private long f3321c; /* renamed from: d, reason: collision with root package name */ private long f3322d; static final class a { /* renamed from: a, reason: collision with root package name */ final Object f3323a; /* renamed from: b, reason: collision with root package name */ final int f3324b; a(Object obj, int i10) { this.f3323a = obj; this.f3324b = i10; } } public g(long j10) { this.f3320b = j10; this.f3321c = j10; } private void g() { h(this.f3321c); } public void b() { h(0L); } protected int f(Object obj) { return 1; } protected synchronized void h(long j10) { while (this.f3322d > j10) { Iterator it = this.f3319a.entrySet().iterator(); Map.Entry entry = (Map.Entry) it.next(); a aVar = (a) entry.getValue(); this.f3322d -= aVar.f3324b; Object key = entry.getKey(); it.remove(); i(key, aVar.f3323a); } } protected void i(Object obj, Object obj2) { } public synchronized Object j(Object obj) { a aVar; aVar = (a) this.f3319a.get(obj); return aVar != null ? aVar.f3323a : null; } public synchronized long k() { return this.f3321c; } public synchronized Object l(Object obj, Object obj2) { int f10 = f(obj2); long j10 = f10; if (j10 >= this.f3321c) { i(obj, obj2); return null; } if (obj2 != null) { this.f3322d += j10; } a aVar = (a) this.f3319a.put(obj, obj2 == null ? null : new a(obj2, f10)); if (aVar != null) { this.f3322d -= aVar.f3324b; if (!aVar.f3323a.equals(obj2)) { i(obj, aVar.f3323a); } } g(); return aVar != null ? aVar.f3323a : null; } public synchronized Object m(Object obj) { a aVar = (a) this.f3319a.remove(obj); if (aVar == null) { return null; } this.f3322d -= aVar.f3324b; return aVar.f3323a; } }