both<T> static method

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

Calculates the number of elements in both sets.

This is equivalent to the intersection cardinality.

Example:

final a = CustomSet<int>([1, 2, 3, 4]);
final b = CustomSet<int>([3, 4, 5, 6]);
print(CardinalityUtils.both(a, b)); // Output: 2

Implementation

static int both<T>(CustomSet<T> a, CustomSet<T> b) =>
    SetOperations.intersection(a, b).cardinality;