mirror of https://git.suyu.dev/suyu/suyu
android: Convert BiMap to Kotlin
parent
8710c6e14c
commit
c02a27ebd2
@ -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 New Issue