训练(题单)功能

This commit is contained in:
masnn committed 2020-04-16 22:19:31 +08:00
1 parent e06283c0cc
commit 97b0d782b9
24 files changed
+466 -105

No files matched your search

+19
View File
@@ -36,3 +36,22 @@ Date.prototype.format = function formatDate(fmt = '%Y-%m-%d %H:%M:%S') {
.replace('%M', this.getMinutes())
.replace('%S', this.getSeconds());
};
Set.isSuperset = function isSuperset(set, subset) {
for (const elem of subset) {
if (!set.has(elem)) return false;
}
return true;
};
Set.union = function union(setA, setB) {
const _union = new Set(setA);
for (const elem of setB) _union.add(elem);
return _union;
};
Set.intersection = function intersection(setA, setB) {
const _intersection = new Set();
for (const elem of setB) {
if (setA.has(elem)) _intersection.add(elem);
}
return _intersection;
};