difference method

CustomSet<T> difference(
  1. CustomSet<T> other
)

Returns the difference of this set with other.

Notation: A - B = {x | x ∈ A and x ∉ B}

The difference contains all elements that are in this set but not in other.

Example:

final a = CustomSet<int>([1, 2, 3, 4, 5]);
final b = CustomSet<int>([2, 4]);
final result = a.difference(b);
// result = {1, 3, 5}

Implementation

CustomSet<T> difference(CustomSet<T> other) =>
    CustomSet(_elements.where((e) => !other._elements.contains(e)));