
org.broadinstitute.hellbender.tools.copynumber.models.FunctionCache Maven / Gradle / Ivy
The newest version!
package org.broadinstitute.hellbender.tools.copynumber.models;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
/**
* @author Samuel Lee <[email protected]>
*/
final class FunctionCache extends LinkedHashMap {
private static final long serialVersionUID = 19841647L;
private static final int MAX_SIZE = 100_000;
private final Function mappingFunction;
FunctionCache(final Function mappingFunction) {
this.mappingFunction = mappingFunction;
}
Double computeIfAbsent(final DATA key) {
return super.computeIfAbsent(key, mappingFunction);
}
@Override
protected boolean removeEldestEntry(final Map.Entry eldest) {
return size() >= MAX_SIZE;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy