TEnumerable.ToLookup<T,TKey,TElement> Method
Overloads
| ToLookup<T,TKey>(IEnumerable<T>, Func<T,TKey>) |
Creates a lookup from a sequence according to a specified key selector function. |
| ToLookup<T,TKey>(IEnumerable<T>, Func<T,TKey>, IEqualityComparer<TKey>) |
Creates a lookup from a sequence according to a specified key selector function. |
| ToLookup<T,TKey,TElement>(IEnumerable<T>, Func<T,TKey>, Func<T,TElement>) |
Creates a lookup from a sequence according to specified key selector and element selector functions. |
| ToLookup<T,TKey,TElement>(IEnumerable<T>, Func<T,TKey>, Func<T,TElement>, IEqualityComparer<TKey>) |
Creates a lookup from a sequence according to a specified key selector function, a comparer and an element selector function. |
Creates a lookup from a sequence according to a specified key selector function.
class function ToLookup<T,TKey>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>): ILookup<TKey,T>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
Parameters
- source
- IEnumerable<T>
The sequence to create a lookup from.
- keySelector
- Func<T, TKey>
A function to extract a key from each element.
Returns
A lookup that contains keys and values. The values within each group are in the same order as in source.
Exceptions
source or keySelector is nil .
Remarks
The method returns a lookup, a one-to-many dictionary that maps keys to collections of values. A lookup differs from a dictionary, which performs a one-to-one mapping of keys to single values.
Creates a lookup from a sequence according to a specified key selector function.
class function ToLookup<T,TKey>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const comparer: IEqualityComparer<TKey>): ILookup<TKey,T>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
Parameters
- source
- IEnumerable<T>
The sequence to create a lookup from.
- keySelector
- Func<T, TKey>
A function to extract a key from each element.
- comparer
- IEqualityComparer<TKey>
An equality comparer to compare keys.
Returns
A lookup that contains keys and values. The values within each group are in the same order as in source.
Exceptions
source or keySelector is nil .
Remarks
The method returns a lookup, a one-to-many dictionary that maps keys
to collections of values. A lookup differs from a dictionary, which
performs a one-to-one mapping of keys to single values.
If comparer is nil , the default equality comparer is
used to compare keys.
Creates a lookup from a sequence according to specified key selector and element selector functions.
class function ToLookup<T,TKey,TElement>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const elementSelector: Func<T, TElement>): ILookup<TKey,TElement>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
- TElement
The type of the value returned by elementSelector .
Parameters
- source
- IEnumerable<T>
The sequence to create a lookup from.
- keySelector
- Func<T, TKey>
A function to extract a key from each element.
- elementSelector
- Func<T, TElement>
A transform function to produce a result element value from each element.
Returns
A lookup that contains values of type TElement selected from
the input sequence.
Exceptions
source or keySelector is nil .
Remarks
The method returns a lookup, a one-to-many dictionary that maps keys to collections of values. A lookup differs from a dictionary, which performs a one-to-one mapping of keys to single values.
Creates a lookup from a sequence according to a specified key selector function, a comparer and an element selector function.
class function ToLookup<T,TKey,TElement>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const elementSelector: Func<T, TElement>; const comparer: IEqualityComparer<TKey>): ILookup<TKey,TElement>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
- TElement
The type of the value returned by elementSelector .
Parameters
- source
- IEnumerable<T>
The sequence to create a lookup from.
- keySelector
- Func<T, TKey>
A function to extract a key from each element.
- elementSelector
- Func<T, TElement>
A transform function to produce a result element value from each element.
- comparer
- IEqualityComparer<TKey>
An equality comparer to compare keys.
Returns
A lookup that contains values of type TElement selected from
the input sequence.
Exceptions
source or keySelector or elementSelector is nil .
Remarks
The method returns a lookup, a one-to-many dictionary that maps keys
to collections of values. A lookup differs from a dictionary, which
performs a one-to-one mapping of keys to single values.
If comparer is nil , the default equality comparer is
used to compare keys.