groupByE<TKey> method

Enumerable<Grouping<TKey, T>> groupByE <TKey>(Selector<T, TKey> keySelector, { EqualityComparer<TKey> keyComparer })

Groups the elements in the enumerable by a key.

After applying the groupByE method to an enumerable, the resulting enumerable will be a series of groups of elements. Each group will consist of all elements in the source enumerable that share a common key as defined by passing the element to the keySelector function.

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

(For the groupByE method, only the comparer and hasher properties of the EqualityComparer need be supplied.)

The resulting enumerable will consist of a series of IGrouping constructs that contain the elements. If no two elements in the enumerable share a common key, the resulting enumerable will consist of IGrouping objects (each containing a single element) of the same length as the source enumerable.

Implementation

Enumerable<Grouping<TKey, T>> groupByE<TKey>(Selector<T, TKey> keySelector,
    {EqualityComparer<TKey> keyComparer}) {
  assert(keySelector != null);
  return GroupByEnumerable<T, TKey>(this, keySelector, keyComparer);
}