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

com.strumenta.kolasu.lionweb.BiMap.kt Maven / Gradle / Ivy

There is a newer version: 1.5.73
Show newest version
package com.strumenta.kolasu.lionweb

class BiMap {
    val `as`: Set
        get() = _asToBs.keys
    val bs: Set
        get() = _bsToAs.keys
    val asToBsMap: Map
        get() = _asToBs
    val bsToAsMap: Map
        get() = _bsToAs

    private val _asToBs = mutableMapOf()
    private val _bsToAs = mutableMapOf()

    fun associate(a: A, b: B) {
        _asToBs[a] = b
        _bsToAs[b] = a
    }

    fun byA(a: A): B? = _asToBs[a]
    fun byB(b: B): A? = _bsToAs[b]

    fun containsA(a: A): Boolean = _asToBs.containsKey(a)
    fun containsB(b: B): Boolean = _bsToAs.containsKey(b)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy