cartesianProductCardinality<T, U> static method
Calculates the cardinality of the Cartesian product of two sets.
Formula: |A × B| = |A| × |B|
If either set is empty, the result is 0.
Example:
final a = CustomSet<int>([1, 2, 3]);
final b = CustomSet<String>(['a', 'b']);
print(CardinalityUtils.cartesianProductCardinality(a, b)); // Output: 6
Implementation
static int cartesianProductCardinality<T, U>(
CustomSet<T> a,
CustomSet<U> b,
) => a.isEmpty || b.isEmpty ? 0 : a.cardinality * b.cardinality;