2019-07-03 03:19:23 +00:00
|
|
|
function getOrSet(container, key, newValue) {
|
|
|
|
|
let val = container.get(key);
|
|
|
|
|
if (!val) {
|
|
|
|
|
val = newValue;
|
|
|
|
|
container.set(key, val);
|
|
|
|
|
}
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function intersects(set1, set2) {
|
|
|
|
|
for (let item of set1) {
|
|
|
|
|
if (set2.has(item)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2019-07-05 16:18:22 +00:00
|
|
|
|
2019-07-09 17:30:09 +00:00
|
|
|
function asymDifference(set1, set2) {
|
|
|
|
|
let ret = new Set();
|
|
|
|
|
for (let item of set1) {
|
|
|
|
|
if (!set2.has(item)) {
|
|
|
|
|
ret.add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-07 22:28:38 +00:00
|
|
|
<!--# include file="MinHeap.js" -->
|
2019-07-07 21:47:16 +00:00
|
|
|
<!--# include file="StringMap.js" -->
|