complement method

CustomSet<T> complement(
  1. CustomSet<T> universal
)

Returns the complement of this set with respect to universal.

Notation: A' or A̅ = {x | x ∈ U and x ∉ A}

The complement contains all elements in the universal set that are not in this set.

Example:

final universal = CustomSet<int>([1, 2, 3, 4, 5, 6, 7, 8, 9]);
final a = CustomSet<int>([1, 3, 7, 9]);
final result = a.complement(universal);
// result = {2, 4, 6, 8}

Implementation

CustomSet<T> complement(CustomSet<T> universal) =>
    CustomSet(universal._elements.where((e) => !_elements.contains(e)));