Move (copy, so far) all the digraph code in Graph
This commit is contained in:
18
utils.js
18
utils.js
@@ -6,3 +6,21 @@ function randStr32() {
|
||||
function randStr64() {
|
||||
return randStr32() + randStr32();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user