fix two_way_map invalid error, Duplicated

This commit is contained in:
kdh8219 2023-04-29 00:39:22 +09:00
parent 2d772838de
commit 4ead835c7b

View file

@ -14,7 +14,7 @@ export default class TwoWayMap<T1, T2> {
}
set_by_first(first: T1, second: T2) {
const secondGet = this.secondMap.get(second);
if (!secondGet) {
if (secondGet) {
throw new Error("Duplicate second argument");
}
this.firstMap.set(first, second);
@ -22,7 +22,7 @@ export default class TwoWayMap<T1, T2> {
}
set_by_second(first: T1, second: T2) {
const firstGet = this.firstMap.get(first);
if (!firstGet) {
if (firstGet) {
throw new Error("Duplicate first argument");
}
this.firstMap.set(first, second);