Computes the intersection of two ISet instances.
Returns a new set containing only the elements that are present in both input sets. This operation is commutative: intersection(a, b) === intersection(b, a).
intersection(a, b) === intersection(b, a)
Performance: O(min(n, m)) where n and m are the sizes of the input sets.
The type of the elements.
The first set.
The second set.
A new ISet instance containing elements common to both sets.
const left = ISet.create<number>([1, 2, 3]);const right = ISet.create<number>([2, 4]);const overlap = ISet.intersection(left, right);assert.deepStrictEqual(Array.from(overlap), [2]); Copy
const left = ISet.create<number>([1, 2, 3]);const right = ISet.create<number>([2, 4]);const overlap = ISet.intersection(left, right);assert.deepStrictEqual(Array.from(overlap), [2]);
Computes the intersection of two ISet instances.
Returns a new set containing only the elements that are present in both input sets. This operation is commutative:
intersection(a, b) === intersection(b, a)
.Performance: O(min(n, m)) where n and m are the sizes of the input sets.