All Downloads are FREE. Search and download functionalities are using the official Maven repository.

geotrellis.proj4.Memoize.scala Maven / Gradle / Ivy

Go to download

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