ParallelEnumerable.ToDictionary 方法

定义

重载

ToDictionary<TSource,TKey,TElement>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

根据指定的键选择器和元素选择器函数,从 Dictionary<TKey,TValue> 创建一个 ParallelQuery<TSource>Creates a Dictionary<TKey,TValue> from a ParallelQuery<TSource> according to specified key selector and element selector functions.

ToDictionary<TSource,TKey,TElement>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

根据指定的键选择器函数、比较器和元素选择器函数,从 Dictionary<TKey,TValue> 创建一个 ParallelQuery<TSource>Creates a Dictionary<TKey,TValue> from a ParallelQuery<TSource> according to a specified key selector function, a comparer, and an element selector function.

ToDictionary<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数,从 Dictionary<TKey,TValue> 创建一个 ParallelQuery<TSource>Creates a Dictionary<TKey,TValue> from a ParallelQuery<TSource> according to a specified key selector function.

ToDictionary<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数和键比较器,从 Dictionary<TKey,TValue> 创建一个 ParallelQuery<TSource>Creates a Dictionary<TKey,TValue> from a ParallelQuery<TSource> according to a specified key selector function and key comparer.

ToDictionary<TSource,TKey,TElement>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

根据指定的键选择器和元素选择器函数,从 Dictionary<TKey,TValue> 创建一个 ParallelQuery<TSource>Creates a Dictionary<TKey,TValue> from a ParallelQuery<TSource> according to specified key selector and element selector functions.

public:
generic <typename TSource, typename TKey, typename TElement>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::Dictionary<TKey, TElement> ^ ToDictionary(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, TKey> ^ keySelector, Func<TSource, TElement> ^ elementSelector);
public static System.Collections.Generic.Dictionary<TKey,TElement> ToDictionary<TSource,TKey,TElement> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TElement> elementSelector);
static member ToDictionary : System.Linq.ParallelQuery<'Source> * Func<'Source, 'Key> * Func<'Source, 'Element> -> System.Collections.Generic.Dictionary<'Key, 'Element>
<Extension()>
Public Function ToDictionary(Of TSource, TKey, TElement) (source As ParallelQuery(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement)) As Dictionary(Of TKey, TElement)

类型参数

TSource

source 的元素类型。The type of the elements of source.

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

TElement

elementSelector 返回的值的类型。The type of the value returned by elementSelector.

参数

source
ParallelQuery<TSource>

据其创建 Dictionary<TKey,TValue> 的序列。A sequence to create a Dictionary<TKey,TValue> from.

keySelector
Func<TSource,TKey>

用于从每个元素中提取键的函数。A function to extract a key from each element.

elementSelector
Func<TSource,TElement>

用于从每个元素产生结果元素值的转换函数。A transform function to produce a result element value from each element.

返回

Dictionary<TKey,TElement>

一个 Dictionary<TKey,TValue>,包含从输入序列中选择的类型为 TElement 的值。A Dictionary<TKey,TValue> that contains values of type TElement selected from the input sequence

异常

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

sourcekeySelectorelementSelector 是 null 引用(在 Visual Basic 中为 Nothing)。source or keySelector or elementSelector is a null reference (Nothing in Visual Basic).

keySelector 生成一个为 null 引用的键(在 Visual Basic 中为 Nothing)。keySelector produces a key that is a null reference (Nothing in Visual Basic). - 或 - keySelector 为两个元素产生了重复键。-or- keySelector produces duplicate keys for two elements. 或评估查询期间发生一个或多个异常。-or- One or more exceptions occurred during the evaluation of the query.

另请参阅

ToDictionary<TSource,TKey,TElement>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

根据指定的键选择器函数、比较器和元素选择器函数,从 Dictionary<TKey,TValue> 创建一个 ParallelQuery<TSource>Creates a Dictionary<TKey,TValue> from a ParallelQuery<TSource> according to a specified key selector function, a comparer, and an element selector function.

public:
generic <typename TSource, typename TKey, typename TElement>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::Dictionary<TKey, TElement> ^ ToDictionary(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, TKey> ^ keySelector, Func<TSource, TElement> ^ elementSelector, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public static System.Collections.Generic.Dictionary<TKey,TElement> ToDictionary<TSource,TKey,TElement> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TElement> elementSelector, System.Collections.Generic.IEqualityComparer<TKey> comparer);
static member ToDictionary : System.Linq.ParallelQuery<'Source> * Func<'Source, 'Key> * Func<'Source, 'Element> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.Dictionary<'Key, 'Element>
<Extension()>
Public Function ToDictionary(Of TSource, TKey, TElement) (source As ParallelQuery(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement), comparer As IEqualityComparer(Of TKey)) As Dictionary(Of TKey, TElement)

类型参数

TSource

source 的元素类型。The type of the elements of source.

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

TElement

elementSelector 返回的值的类型。The type of the value returned by elementSelector.

参数

source
ParallelQuery<TSource>

据其创建 Dictionary<TKey,TValue> 的序列。A sequence to create a Dictionary<TKey,TValue> from.

keySelector
Func<TSource,TKey>

用于从每个元素中提取键的函数。A function to extract a key from each element.

elementSelector
Func<TSource,TElement>

用于从每个元素产生结果元素值的转换函数。A transform function to produce a result element value from each element.

comparer
IEqualityComparer<TKey>

用于比较键的 IEqualityComparer<T>An IEqualityComparer<T> to compare keys.

返回

Dictionary<TKey,TElement>

一个 Dictionary<TKey,TValue>,包含从输入序列中选择的类型为 TElement 的值。A Dictionary<TKey,TValue> that contains values of type TElement selected from the input sequence

异常

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

sourcekeySelectorelementSelector 是 null 引用(在 Visual Basic 中为 Nothing)。source or keySelector or elementSelector is a null reference (Nothing in Visual Basic).

keySelector 生成一个为 null 引用的键(在 Visual Basic 中为 Nothing)。keySelector produces a key that is a null reference (Nothing in Visual Basic). - 或 - keySelector 为两个元素产生了重复键。-or- keySelector produces duplicate keys for two elements. 或评估查询期间发生一个或多个异常。-or- One or more exceptions occurred during the evaluation of the query.

另请参阅

ToDictionary<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数,从 Dictionary<TKey,TValue> 创建一个 ParallelQuery<TSource>Creates a Dictionary<TKey,TValue> from a ParallelQuery<TSource> according to a specified key selector function.

public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::Dictionary<TKey, TSource> ^ ToDictionary(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, TKey> ^ keySelector);
public static System.Collections.Generic.Dictionary<TKey,TSource> ToDictionary<TSource,TKey> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector);
static member ToDictionary : System.Linq.ParallelQuery<'Source> * Func<'Source, 'Key> -> System.Collections.Generic.Dictionary<'Key, 'Source>
<Extension()>
Public Function ToDictionary(Of TSource, TKey) (source As ParallelQuery(Of TSource), keySelector As Func(Of TSource, TKey)) As Dictionary(Of TKey, TSource)

类型参数

TSource

source 的元素类型。The type of the elements of source.

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

参数

source
ParallelQuery<TSource>

据其创建 Dictionary<TKey,TValue> 的序列。A sequence to create a Dictionary<TKey,TValue> from.

keySelector
Func<TSource,TKey>

用于从每个元素中提取键的函数。A function to extract a key from each element.

返回

Dictionary<TKey,TSource>

一个包含键和值的 Dictionary<TKey,TValue>A Dictionary<TKey,TValue> that contains keys and values.

异常

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

sourcekeySelector 为 null 引用(在 Visual Basic 中为 Nothing)。source or keySelector is a null reference (Nothing in Visual Basic).

keySelector 生成一个为 null 引用的键(在 Visual Basic 中为 Nothing)。keySelector produces a key that is a null reference (Nothing in Visual Basic). - 或 - keySelector 为两个元素产生了重复键。-or- keySelector produces duplicate keys for two elements. 或评估查询期间发生一个或多个异常。-or- One or more exceptions occurred during the evaluation of the query.

另请参阅

ToDictionary<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数和键比较器,从 Dictionary<TKey,TValue> 创建一个 ParallelQuery<TSource>Creates a Dictionary<TKey,TValue> from a ParallelQuery<TSource> according to a specified key selector function and key comparer.

public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
 static System::Collections::Generic::Dictionary<TKey, TSource> ^ ToDictionary(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, TKey> ^ keySelector, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public static System.Collections.Generic.Dictionary<TKey,TSource> ToDictionary<TSource,TKey> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey> comparer);
static member ToDictionary : System.Linq.ParallelQuery<'Source> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.Dictionary<'Key, 'Source>
<Extension()>
Public Function ToDictionary(Of TSource, TKey) (source As ParallelQuery(Of TSource), keySelector As Func(Of TSource, TKey), comparer As IEqualityComparer(Of TKey)) As Dictionary(Of TKey, TSource)

类型参数

TSource

source 的元素类型。The type of the elements of source.

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

参数

source
ParallelQuery<TSource>

据其创建 Dictionary<TKey,TValue> 的序列。A sequence to create a Dictionary<TKey,TValue> from.

keySelector
Func<TSource,TKey>

用于从每个元素中提取键的函数。A function to extract a key from each element.

comparer
IEqualityComparer<TKey>

用于比较键的 IEqualityComparer<T>An IEqualityComparer<T> to compare keys.

返回

Dictionary<TKey,TSource>

一个包含键和值的 Dictionary<TKey,TValue>A Dictionary<TKey,TValue> that contains keys and values.

异常

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

sourcekeySelector 为 null 引用(在 Visual Basic 中为 Nothing)。source or keySelector is a null reference (Nothing in Visual Basic).

keySelector 生成一个为 null 引用的键(在 Visual Basic 中为 Nothing)。keySelector produces a key that is a null reference (Nothing in Visual Basic). - 或 - keySelector 为两个元素产生了重复键。-or- keySelector produces duplicate keys for two elements. 或评估查询期间发生一个或多个异常。-or- One or more exceptions occurred during the evaluation of the query.

另请参阅

适用于