neither<T> static method

int neither<T>(
  1. CustomSet<T> a,
  2. CustomSet<T> b,
  3. CustomSet<T> universal
)

Calculates the number of elements in neither set (relative to universal).

Formula: |U| - |A ∪ B|

Example:

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

Implementation

static int neither<T>(
  CustomSet<T> a,
  CustomSet<T> b,
  CustomSet<T> universal,
) {
  final unionCard = unionCardinality(a, b);
  return universal.cardinality - unionCard;
}