com.github.underscore.MemoizeFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of underscore8 Show documentation
Show all versions of underscore8 Show documentation
The java 8 port of Underscore.js
The newest version!
package com.github.underscore;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
public abstract class MemoizeFunction implements Function {
private final Map cache = new LinkedHashMap();
public abstract T calc(final F n);
public T apply(final F key) {
if (!cache.containsKey(key)) {
cache.put(key, calc(key));
}
return cache.get(key);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy