android: Convert BiMap to Kotlin
This commit is contained in:
parent
8710c6e14c
commit
c02a27ebd2
2 changed files with 22 additions and 22 deletions
|
@ -1,22 +0,0 @@
|
|||
package org.yuzu.yuzu_emu.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BiMap<K, V> {
|
||||
private Map<K, V> forward = new HashMap<K, V>();
|
||||
private Map<V, K> backward = new HashMap<V, K>();
|
||||
|
||||
public synchronized void add(K key, V value) {
|
||||
forward.put(key, value);
|
||||
backward.put(value, key);
|
||||
}
|
||||
|
||||
public synchronized V getForward(K key) {
|
||||
return forward.get(key);
|
||||
}
|
||||
|
||||
public synchronized K getBackward(V key) {
|
||||
return backward.get(key);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package org.yuzu.yuzu_emu.utils
|
||||
|
||||
class BiMap<K, V> {
|
||||
private val forward: MutableMap<K, V> = HashMap()
|
||||
private val backward: MutableMap<V, K> = HashMap()
|
||||
|
||||
@Synchronized
|
||||
fun add(key: K, value: V) {
|
||||
forward[key] = value
|
||||
backward[value] = key
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun getForward(key: K): V? {
|
||||
return forward[key]
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun getBackward(key: V): K? {
|
||||
return backward[key]
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue