Distinct method

Enumerable<T> Distinct ({EqualityComparer<T> comparer })

Returns an enumerable representing the distinct values of this enumerable.

After applying the Distinct method to an enumerable, the resulting enumerable will consist of distinct values in the source enumerable.

Optionally, an EqualityComparer can be supplied to handle comparisons. If one is provided, the Distinct method will use the comparer property in order to determine equivalency. If omitted, Distinct will resort to strict equivalency (i.e. checking if (value == element)).

(For the Distinct method, only the comparer property of the EqualityComparer need be supplied.)

Each element will be the first element found in the source enumerable, meaning elements with unique data that are deemed non-distinct by the comparer will be dropped.

If none of the elements in the enumerable match any other element in the enumerable, the enumerable will be unchanged.

Implementation

Enumerable<T> Distinct({EqualityComparer<T> comparer}) {
  return DistinctEnumerable<T>(this, comparer);
}