symmetricDifference method
Returns the symmetric difference of this set with other.
Notation: A ⊕ B = (A ∪ B) - (A ∩ B)
The symmetric difference contains all elements that are in either set but not in both.
Example:
final a = CustomSet<int>([2, 4, 6]);
final b = CustomSet<int>([2, 3, 5]);
final result = a.symmetricDifference(b);
// result = {3, 4, 5, 6}
Implementation
CustomSet<T> symmetricDifference(CustomSet<T> other) {
final unionSet = union(other);
final intersectionSet = intersection(other);
return unionSet.difference(intersectionSet);
}