2019-07-03 01:42:17 +00:00
|
|
|
function randStr32() {
|
|
|
|
|
let num = Math.floor(Math.random() * Math.pow(2, 32));
|
|
|
|
|
return num.toString(16).padStart(8, '0');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function randStr64() {
|
|
|
|
|
return randStr32() + randStr32();
|
|
|
|
|
}
|
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-07 21:47:16 +00:00
|
|
|
<!--# include file="StringMap.js" -->
|