From bce557cc2dc767628bed6aac87301a1be7c5431b Mon Sep 17 00:00:00 2001 From: rxliuli Date: Tue, 4 Nov 2025 05:03:50 +0800 Subject: init commit --- node_modules/@jet/environment/util/set.js | 92 +++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 node_modules/@jet/environment/util/set.js (limited to 'node_modules/@jet/environment/util/set.js') diff --git a/node_modules/@jet/environment/util/set.js b/node_modules/@jet/environment/util/set.js new file mode 100644 index 0000000..68a1f45 --- /dev/null +++ b/node_modules/@jet/environment/util/set.js @@ -0,0 +1,92 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.difference = exports.symmetricDifference = exports.intersection = exports.union = exports.isSuperset = void 0; +/** + * Test if a Set contains all elements of another Set. + * + * @param set - + * @param subset - + * + * @returns True if set contains all elements of subset, otherwise false. + */ +function isSuperset(set, subset) { + for (const elem of subset) { + if (!set.has(elem)) { + return false; + } + } + return true; +} +exports.isSuperset = isSuperset; +/** + * Construct the union of two Sets. + * + * @param setA - + * @param setB - + * + * @returns A new Set containing all elements from setA and setB. + */ +function union(setA, setB) { + const result = new Set(setA); + for (const elem of setB) { + result.add(elem); + } + return result; +} +exports.union = union; +/** + * Construct the intersection of two Sets. + * + * @param setA - + * @param setB - + * + * @returns A new Set containing only those elements which appear in both setA and setB. + */ +function intersection(setA, setB) { + const result = new Set(); + for (const elem of setB) { + if (setA.has(elem)) { + result.add(elem); + } + } + return result; +} +exports.intersection = intersection; +/** + * Construct the symmetric difference (XOR) of two Sets. + * + * @param setA - + * @param setB - + * + * @returns A new Set containing only those elements which appear in setA or in setB but not in both setA and setB. + */ +function symmetricDifference(setA, setB) { + const result = new Set(setA); + for (const elem of setB) { + if (result.has(elem)) { + result.delete(elem); + } + else { + result.add(elem); + } + } + return result; +} +exports.symmetricDifference = symmetricDifference; +/** + * Construct the difference of two Sets. + * + * @param setA - + * @param setB - + * + * @returns A new Set containing the elements of setA which do not appear in setB. + */ +function difference(setA, setB) { + const result = new Set(setA); + for (const elem of setB) { + result.delete(elem); + } + return result; +} +exports.difference = difference; +//# sourceMappingURL=set.js.map \ No newline at end of file -- cgit v1.2.3