union<T> static method

CustomSet<T> union<T>(
  1. CustomSet<T> a,
  2. CustomSet<T> b
)

Returns the union of two sets.

Notation: A ∪ B = {x | x ∈ A or x ∈ B}

The union contains all elements that are in either set or both.

Example:

final a = CustomSet<int>([2, 5, 8]);
final b = CustomSet<int>([7, 5, 22]);
final result = SetOperations.union(a, b);
// result = {2, 5, 7, 8, 22}

Implementation

static CustomSet<T> union<T>(CustomSet<T> a, CustomSet<T> b) =>
    CustomSet({...a.elements, ...b.elements});