what-the-bank/sources/org/simpleframework/xml/util/LimitedCache.java

43 lines
1014 B
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.simpleframework.xml.util;
import java.util.LinkedHashMap;
import java.util.Map;
/* loaded from: classes.dex */
public class LimitedCache<T> extends LinkedHashMap<Object, T> implements Cache<T> {
private final int capacity;
public LimitedCache() {
this(50000);
}
public LimitedCache(int i) {
this.capacity = i;
}
@Override // org.simpleframework.xml.util.Cache
public void cache(Object obj, T t) {
put(obj, t);
}
@Override // org.simpleframework.xml.util.Cache
public T take(Object obj) {
return remove(obj);
}
@Override // org.simpleframework.xml.util.Cache
public T fetch(Object obj) {
return get(obj);
}
@Override // org.simpleframework.xml.util.Cache
public boolean contains(Object obj) {
return containsKey(obj);
}
@Override // java.util.LinkedHashMap
protected boolean removeEldestEntry(Map.Entry<Object, T> entry) {
return size() > this.capacity;
}
}