cardinality<T> static method

int cardinality<T>(
  1. CustomSet<T> set
)

Returns the cardinality (number of elements) of a set.

Notation: n(A) or |A|

This is a convenience method that returns the cardinality property of the given set.

Example:

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

final empty = CustomSet<int>.empty();
print(CardinalityUtils.cardinality(empty)); // Output: 0

Implementation

static int cardinality<T>(CustomSet<T> set) => set.cardinality;