commonMain.mahjongutils.CalcContext.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mahjong-utils-jvm Show documentation
Show all versions of mahjong-utils-jvm Show documentation
Mahjong Utils (for Japanese Riichi Mahjong)
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