
walkmc.cache.Caches.kt Maven / Gradle / Ivy
package walkmc.cache
import com.google.common.collect.*
import walkmc.extensions.collections.*
import java.util.*
import java.util.concurrent.*
/**
* A skeletal abstract registry used to create new [ICache].
*/
abstract class Cache(
override val delegate: MutableMap = newMutableMap(),
) : ICache
/**
* A standard registry implementation.
*/
open class StandardCache(
delegate: MutableMap = newMutableMap(),
) : Cache(delegate)
/**
* A concurrent registry implementation using [ConcurrentHashMap]
*/
open class ConcurrentCache(
delegate: MutableMap = ConcurrentHashMap(),
) : Cache(delegate)
/**
* A registry used to store bi-directional key-values with [BiMap].
*/
open class BiCache(delegate: BiMap = HashBiMap.create()) : BiMap by delegate
/**
* A registry implementation with [IdentityHashMap].
*/
open class IdCache(
delegate: MutableMap = IdentityHashMap(),
) : Cache(delegate)
/**
* A immutable implementation of [ICache].
*/
open class ImmutableCache(
delegate: Map = emptyMap(),
) : Cache(Collections.unmodifiableMap(delegate))
/**
* A tree map implementation of [ICache].
*/
open class TreeCache(comparator: Comparator? = null) : TreeMap(comparator) {
constructor(comparator: Comparator?, map: Map) : this(comparator) { putAll(map) }
constructor(map: Map) : this(null, map)
constructor(map: SortedMap) : this(map.comparator(), map)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy