complementCardinality<T> static method

int complementCardinality<T>(
  1. CustomSet<T> a,
  2. CustomSet<T> universal
)

Calculates the cardinality of the complement of a set.

Formula: |A'| = |U| - |A|

Where U is the universal set.

Example:

final universal = CustomSet<int>([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
final a = CustomSet<int>([1, 3, 5, 7, 9]);
print(CardinalityUtils.complementCardinality(a, universal)); // Output: 5

Implementation

static int complementCardinality<T>(CustomSet<T> a, CustomSet<T> universal) =>
    universal.cardinality - a.cardinality;