GroupSelect<TKey, TResult> method

Enumerable<TResult> GroupSelect <TKey, TResult>(Selector<T, TKey> keySelector, GroupSelector<TKey, Iterable<T>, TResult> resultSelector, { EqualityComparer<TKey> keyComparer })

Groups the elements in the enumerable by a key and maps the groups to a new element.

After applying the GroupSelect 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. Finally, each group will then be passed to the resultSelector function along with its associated key and the returned value of that function will be returned as an element of the resulting enumerable.

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

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

Implementation

Enumerable<TResult> GroupSelect<TKey, TResult>(Selector<T, TKey> keySelector,
    GroupSelector<TKey, Iterable<T>, TResult> resultSelector,
    {EqualityComparer<TKey> keyComparer}) {
  assert(keySelector != null && resultSelector != null);
  return GroupSelectEnumerable<T, TKey, TResult>(
      this, keySelector, resultSelector, keyComparer);
}