LinqExtensions.ToLookup Method

Definition

Namespace: Numerics.NET.DataAnalysis.Linq
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.2

Overload List

ToLookup<T, TKey>(Vector<T>, Func<T, TKey>) Creates a lookup from a vector according to the specified key selector function.
ToLookup<T, TKey>(Vector<T>, Func<T, TKey>, IEqualityComparer<TKey>) Creates a lookup from a vector according to the specified key selector function and key comparer.
ToLookup<R, C, TKey>(DataFrame<R, C>, Func<DataFrameRow<R, C>, TKey>) Creates a lookup for the data frame according to the specified key selector function.
ToLookup<R, C, TKey>(DataFrame<R, C>, Func<DataFrameRow<R, C>, TKey>, IEqualityComparer<TKey>) Creates a lookup for the data frame according to the specified key selector function and key comparer.
ToLookup<T, TKey, TElement>(Vector<T>, Func<T, TKey>, Func<T, TElement>) Creates a lookup from a vector according to the specified key selector and element selector functions.
ToLookup<T, TKey, TElement>(Vector<T>, Func<T, TKey>, Func<T, TElement>, IEqualityComparer<TKey>) Creates a lookup from a vector according to the specified key selector and element selector functions, and key comparer.
ToLookup<R, C, TKey, TElement>(DataFrame<R, C>, Func<DataFrameRow<R, C>, TKey>, Func<DataFrameRow<R, C>, TElement>) Creates a lookup for the data frame according to the specified key selector and element selector function.
ToLookup<R, C, TKey, TElement>(DataFrame<R, C>, Func<DataFrameRow<R, C>, TKey>, Func<DataFrameRow<R, C>, TElement>, IEqualityComparer<TKey>) Creates a lookup for the data frame according to the specified key selector and element selector function.

ToLookup<R, C, TKey>(DataFrame<R, C>, Func<DataFrameRow<R, C>, TKey>)

Creates a lookup for the data frame according to the specified key selector function.
C#
public static LinqExtensions.DataFrameLookup<TKey, R, C> ToLookup<R, C, TKey>(
	this DataFrame<R, C> frame,
	Func<DataFrameRow<R, C>, TKey> keySelector
)

Parameters

frame  DataFrame<R, C>
A data frame to project.
keySelector  Func<DataFrameRow<R, C>, TKey>
A function to extract a key from each row.

Type Parameters

R
The element type of the row index of the data frame.
C
The element type of the column index of the data frame.
TKey
The type of the key returned by keySelector.

Return Value

LinqExtensions.DataFrameLookup<TKey, R, C>
A LinqExtensions.Lookup<TKey, T> that contains keys and values.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DataFrame<R, C>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullException

frame is null.

-or-

keySelector is null.

ToLookup<T, TKey>(Vector<T>, Func<T, TKey>)

Creates a lookup from a vector according to the specified key selector function.
C#
public static LinqExtensions.Lookup<TKey, T> ToLookup<T, TKey>(
	this Vector<T> vector,
	Func<T, TKey> keySelector
)

Parameters

vector  Vector<T>
The vector to create a lookup from.
keySelector  Func<T, TKey>
A function to extract a key from each element.

Type Parameters

T
The type of the elements of the vector.
TKey
The type of the key returned by the key selector.

Return Value

LinqExtensions.Lookup<TKey, T>
A lookup that contains keys and values.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

ToLookup<R, C, TKey>(DataFrame<R, C>, Func<DataFrameRow<R, C>, TKey>, IEqualityComparer<TKey>)

Creates a lookup for the data frame according to the specified key selector function and key comparer.
C#
public static LinqExtensions.DataFrameLookup<TKey, R, C> ToLookup<R, C, TKey>(
	this DataFrame<R, C> frame,
	Func<DataFrameRow<R, C>, TKey> keySelector,
	IEqualityComparer<TKey> comparer
)

Parameters

frame  DataFrame<R, C>
A data frame to project.
keySelector  Func<DataFrameRow<R, C>, TKey>
A function to extract a key from each row.
comparer  IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys.

Type Parameters

R
The element type of the row index of the data frame.
C
The element type of the column index of the data frame.
TKey
The type of the key returned by keySelector.

Return Value

LinqExtensions.DataFrameLookup<TKey, R, C>
A LinqExtensions.Lookup<TKey, T> that contains keys and values.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DataFrame<R, C>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

If comparer is null, the Default is used to compare keys.

Exceptions

ArgumentNullException

frame is null.

-or-

keySelector is null.

ToLookup<R, C, TKey, TElement>(DataFrame<R, C>, Func<DataFrameRow<R, C>, TKey>, Func<DataFrameRow<R, C>, TElement>)

Creates a lookup for the data frame according to the specified key selector and element selector function.
C#
public static LinqExtensions.Lookup<TKey, TElement> ToLookup<R, C, TKey, TElement>(
	this DataFrame<R, C> frame,
	Func<DataFrameRow<R, C>, TKey> keySelector,
	Func<DataFrameRow<R, C>, TElement> elementSelector
)

Parameters

frame  DataFrame<R, C>
A data frame to project.
keySelector  Func<DataFrameRow<R, C>, TKey>
A function to extract a key from each row.
elementSelector  Func<DataFrameRow<R, C>, TElement>
A function that transforms each row into a result.

Type Parameters

R
The element type of the row index of the data frame.
C
The element type of the column index of the data frame.
TKey
The type of the key returned by keySelector.
TElement
The type of the result returned by elementSelector.

Return Value

LinqExtensions.Lookup<TKey, TElement>
A LinqExtensions.Lookup<TKey, T> that contains keys and values.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DataFrame<R, C>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullException

frame is null.

-or-

keySelector is null.

-or-

elementSelector is null.

ToLookup<T, TKey>(Vector<T>, Func<T, TKey>, IEqualityComparer<TKey>)

Creates a lookup from a vector according to the specified key selector function and key comparer.
C#
public static LinqExtensions.Lookup<TKey, T> ToLookup<T, TKey>(
	this Vector<T> vector,
	Func<T, TKey> keySelector,
	IEqualityComparer<TKey> comparer
)

Parameters

vector  Vector<T>
The vector to create a lookup from.
keySelector  Func<T, TKey>
A function to extract a key from each element.
comparer  IEqualityComparer<TKey>
An object that compares two keys for equality.

Type Parameters

T
The type of the elements of the vector.
TKey
The type of the key returned by the key selector.

Return Value

LinqExtensions.Lookup<TKey, T>
A lookup that contains keys and values.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

ToLookup<T, TKey, TElement>(Vector<T>, Func<T, TKey>, Func<T, TElement>)

Creates a lookup from a vector according to the specified key selector and element selector functions.
C#
public static LinqExtensions.Lookup<TKey, TElement> ToLookup<T, TKey, TElement>(
	this Vector<T> vector,
	Func<T, TKey> keySelector,
	Func<T, TElement> elementSelector
)

Parameters

vector  Vector<T>
The vector to create a lookup from.
keySelector  Func<T, TKey>
A function to extract a key from each element.
elementSelector  Func<T, TElement>
A function that transforms each input element.

Type Parameters

T
The type of the elements of the vector.
TKey
The type of the key returned by the key selector.
TElement
The type of the value returned by the element selector.

Return Value

LinqExtensions.Lookup<TKey, TElement>
A lookup that contains keys and values selected from the input using elementSelector.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

ToLookup<R, C, TKey, TElement>(DataFrame<R, C>, Func<DataFrameRow<R, C>, TKey>, Func<DataFrameRow<R, C>, TElement>, IEqualityComparer<TKey>)

Creates a lookup for the data frame according to the specified key selector and element selector function.
C#
public static LinqExtensions.Lookup<TKey, TElement> ToLookup<R, C, TKey, TElement>(
	this DataFrame<R, C> frame,
	Func<DataFrameRow<R, C>, TKey> keySelector,
	Func<DataFrameRow<R, C>, TElement> elementSelector,
	IEqualityComparer<TKey> comparer
)

Parameters

frame  DataFrame<R, C>
A data frame to project.
keySelector  Func<DataFrameRow<R, C>, TKey>
A function to extract a key from each row.
elementSelector  Func<DataFrameRow<R, C>, TElement>
A function that transforms each row into a result.
comparer  IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys.

Type Parameters

R
The element type of the row index of the data frame.
C
The element type of the column index of the data frame.
TKey
The type of the key returned by keySelector.
TElement
The type of the result returned by elementSelector.

Return Value

LinqExtensions.Lookup<TKey, TElement>
A LinqExtensions.Lookup<TKey, T> that contains keys and values.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DataFrame<R, C>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

If comparer is null, the Default is used to compare keys.

Exceptions

ArgumentNullException

frame is null.

-or-

keySelector is null.

-or-

elementSelector is null.

ToLookup<T, TKey, TElement>(Vector<T>, Func<T, TKey>, Func<T, TElement>, IEqualityComparer<TKey>)

Creates a lookup from a vector according to the specified key selector and element selector functions, and key comparer.
C#
public static LinqExtensions.Lookup<TKey, TElement> ToLookup<T, TKey, TElement>(
	this Vector<T> vector,
	Func<T, TKey> keySelector,
	Func<T, TElement> elementSelector,
	IEqualityComparer<TKey> comparer
)

Parameters

vector  Vector<T>
The vector to create a lookup from.
keySelector  Func<T, TKey>
A function to extract a key from each element.
elementSelector  Func<T, TElement>
A function that transforms each input element.
comparer  IEqualityComparer<TKey>
An object that compares two keys for equality.

Type Parameters

T
The type of the elements of the vector.
TKey
The type of the key returned by the key selector.
TElement
The type of the value returned by the element selector.

Return Value

LinqExtensions.Lookup<TKey, TElement>
A lookup that contains keys and values selected from the input using elementSelector.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also