![JAR search and dependency download from the Maven repository](/logo.png)
com.github.TKnudsen.ComplexDataObject.model.tools.Functions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of complex-data-object Show documentation
Show all versions of complex-data-object Show documentation
A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.
The newest version!
package com.github.TKnudsen.ComplexDataObject.model.tools;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
public class Functions {
/**
* useful if computation is expensive and values remain constant. Do not use
* this if function values may change over time.
*
* @param
* @param
* @param f
* @return
*/
public static Function bufferedFunction(Function f) {
Map buffer = new HashMap<>();
return new Function() {
@Override
public R apply(T t) {
if (buffer.containsKey(t))
return buffer.get(t);
buffer.put(t, f.apply(t));
return buffer.get(t);
}
};
}
private Functions() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy