associativeUnion<T> static method

bool associativeUnion<T>(
  1. CustomSet<T> a,
  2. CustomSet<T> b,
  3. CustomSet<T> c
)

Verifies the Associative Law for Union.

Law: A ∪ (B ∪ C) = (A ∪ B) ∪ C

The grouping of sets in a union operation does not matter.

Implementation

static bool associativeUnion<T>(
  CustomSet<T> a,
  CustomSet<T> b,
  CustomSet<T> c,
) {
  final left = SetOperations.union(a, SetOperations.union(b, c));
  final right = SetOperations.union(SetOperations.union(a, b), c);
  return left.equals(right);
}