
commonMain.casperix.math.array.FunctionCache.kt Maven / Gradle / Ivy
package casperix.math.array
import casperix.math.function.Function2D
import casperix.math.vector.int32.Vector2i
import kotlin.math.roundToInt
class FunctionCache(val source: Function2D, val cache: CustomMap2D) {
val get: Function2D = { x, y ->
val value = source(x, y)
val pos = Vector2i(x.roundToInt(), y.roundToInt())
if (cache.isInside(pos)) {
cache.set(pos, value)
}
value
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy