export class SetUtils {
  static union(set0, set1) {
    const newSet = new Set();
    set0.forEach((val) => newSet.add(val));
    set1.forEach((val) => newSet.add(val));
    return newSet;
  }
  static intersection(set0, set1) {
    const newSet = new Set();
    set0.forEach((val) => {
      if (set1.has(val)) {
        newSet.add(val);
      }
    });
    set1.forEach((val) => {
      if (set0.has(val)) {
        newSet.add(val);
      }
    });
    return newSet;
  }
  static difference(set0, set1) {
    const newSet = new Set();
    set0.forEach((val) => {
      if (!set1.has(val)) {
        newSet.add(val);
      }
    });
    set1.forEach((val) => {
      if (!set0.has(val)) {
        newSet.add(val);
      }
    });
    return newSet;
  }
}
