* Returns a new set with elements in this set but not in otherSet. * @param otherSet - The set to subtract * @returns A new set with the difference * @complexity Time O(n) | Space O(n)
(otherSet: MySet)
| 138 | * @complexity Time O(n) | Space O(n) |
| 139 | */ |
| 140 | difference(otherSet: MySet): MySet { |
| 141 | const differenceSet = new MySet(); |
| 142 | this.values().forEach(value => { |
| 143 | if (!otherSet.has(value)) { |
| 144 | differenceSet.add(value); |
| 145 | } |
| 146 | }); |
| 147 | return differenceSet; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Returns true if every element of this set is also in otherSet. |
no test coverage detected