com.olapdb.core.utils.LruBatchReclaimCache Maven / Gradle / Ivy
The newest version!
package com.olapdb.core.utils;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
public class LruBatchReclaimCache extends LinkedHashMap {
private int capacity;
public LruBatchReclaimCache(int capacity) {
super(100, 0.75f, true);
this.capacity = capacity;
}
public int getCapacity() {
return capacity;
}
public List trimToSize(int size){
List removes = new Vector<>();
while(this.size() > size){
final Map.Entry toEvict = this.entrySet().iterator().next();
removes.add( this.remove(toEvict.getKey()));
}
return removes;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy