symmetricDifference<T> static method

CustomSet<T> symmetricDifference<T>(
  1. CustomSet<T> a,
  2. CustomSet<T> b
)

Returns the symmetric difference of two sets.

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 = SetOperations.symmetricDifference(a, b);
// result = {3, 4, 5, 6}

Implementation

static CustomSet<T> symmetricDifference<T>(CustomSet<T> a, CustomSet<T> b) {
  final unionSet = union(a, b);
  final intersectionSet = intersection(a, b);
  return difference(unionSet, intersectionSet);
}