GroupSelectValue<TKey, TValue, TResult> method
Groups the elements in the enumerable by a key, maps the elements to a new value, and maps the groups to a new element.
After applying the GroupSelectValue 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 stored as a value
obtained by passing the elements to the valueSelector
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 GroupSelectValue method will use the comparer
and
hasher
properties in order to determine equivalency. If omitted,
GroupSelectValue will resort to strict equivalency (i.e. checking if
(value == element)
).
(For the GroupSelectValue method, only the comparer
and hasher
properties of the EqualityComparer need be supplied.)
Implementation
Enumerable<TResult> GroupSelectValue<TKey, TValue, TResult>(
Selector<T, TKey> keySelector,
Selector<T, TValue> valueSelector,
GroupSelector<TKey, Iterable<TValue>, TResult> resultSelector,
{EqualityComparer<TKey> keyComparer}) {
assert(
keySelector != null && valueSelector != null && resultSelector != null);
return GroupSelectValueEnumerable<T, TKey, TValue, TResult>(
this, keySelector, valueSelector, resultSelector, keyComparer);
}