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

commonMain.mahjongutils.CalcContext.kt Maven / Gradle / Ivy

There is a newer version: 0.7.6
Show newest version
package mahjongutils

class CalcContext {
    @PublishedApi
    internal val cache = HashMap()

    inline fun  memo(key: Any?, calc: () -> T): T {
        if (cache.containsKey(key)) {
            return cache[key] as T
        }
        return calc().also {
            cache[key] = it
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy