
geotrellis.proj4.Memoize.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geotrellis-proj4_2.11 Show documentation
Show all versions of geotrellis-proj4_2.11 Show documentation
GeoTrellis is an open source geographic data processing engine for high performance applications.
The newest version!
package geotrellis.proj4
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Manuri Perera
*/
class Memoize[T, R](f: T => R) extends (T => R) {
val map: ConcurrentHashMap[T, R] = new ConcurrentHashMap()
def apply(x: T): R = {
if (map.contains(x)) map.get(x)
else {
val y = f(x)
map.put(x, y)
y
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy