/**
* Returns a `HashSet` of values which are present in both this set and that
* `Iterable`.
*
* **NOTE**: the hash and equal of the values in both the set and the iterable
* must be the same.
*
* @tsplus static HashSet.Aspects intersection
* @tsplus pipeable HashSet intersection
*/
export function intersection(that: Iterable) {
return (self: HashSet): HashSet => {
const set = HashSet.empty()
return set.mutate((_) => {
for (const k of that) {
if (self.has(k)) {
_.add(k)
}
}
})
}
}