ConcurrentDictionary<TKey,TValue> 构造函数

定义

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例。

重载

ConcurrentDictionary<TKey,TValue>()

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例为空,具有默认的并发级别和默认的初始容量,并为键类型使用默认比较器。

ConcurrentDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>)

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例包含从指定的 IEnumerable<T> 中复制的元素,具有默认的并发级别和默认的初始容量,并为键类型使用默认比较器。

ConcurrentDictionary<TKey,TValue>(IEqualityComparer<TKey>)

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例为空,具有默认的并发级别和容量,并使用指定的 IEqualityComparer<T>

ConcurrentDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)

初始化 类的新实例,该类 ConcurrentDictionary<TKey,TValue> 包含从指定的 IEnumerable 复制的元素具有默认并发级别,具有默认的初始容量,并使用指定的 IEqualityComparer<T>

ConcurrentDictionary<TKey,TValue>(Int32, Int32)

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例为空,具有指定的并发级别和容量,并为键类型使用默认比较器。

ConcurrentDictionary<TKey,TValue>(Int32, IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例包含从指定的 IEnumerable 中复制的元素并使用指定的 IEqualityComparer<T>

ConcurrentDictionary<TKey,TValue>(Int32, Int32, IEqualityComparer<TKey>)

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例为空,具有指定的并发级别和指定的初始容量,并使用指定的 IEqualityComparer<T>

ConcurrentDictionary<TKey,TValue>()

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例为空,具有默认的并发级别和默认的初始容量,并为键类型使用默认比较器。

public:
 ConcurrentDictionary();
public ConcurrentDictionary ();
Public Sub New ()

注解

默认并发级别等于 CPU 数。 并发级别越高,可以在不干扰和阻塞的情况下执行更多并发写入操作。 较高的并发级别值还会导致需要所有锁 (的操作(例如,表大小 ToArray 调整和 Count) )变得更加昂贵。 默认容量 (DEFAULT_CAPACITY) 表示初始存储桶数,是在构造大型字典时,非常小的字典的大小与重设大小的次数之间的权衡。 此外,容量不应由小质数进行除法。 默认容量为 31。

另请参阅

适用于

ConcurrentDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例包含从指定的 IEnumerable<T> 中复制的元素,具有默认的并发级别和默认的初始容量,并为键类型使用默认比较器。

public:
 ConcurrentDictionary(System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>> ^ collection);
public ConcurrentDictionary (System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : seq<System.Collections.Generic.KeyValuePair<'Key, 'Value>> -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)))

参数

collection
IEnumerable<KeyValuePair<TKey,TValue>>

IEnumerable<T>,它的元素被复制到新 ConcurrentDictionary<TKey,TValue>

例外

collection 或其任何键为 null

collection 包含一个或多个重复键。

另请参阅

适用于

ConcurrentDictionary<TKey,TValue>(IEqualityComparer<TKey>)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例为空,具有默认的并发级别和容量,并使用指定的 IEqualityComparer<T>

public:
 ConcurrentDictionary(System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public ConcurrentDictionary (System.Collections.Generic.IEqualityComparer<TKey> comparer);
public ConcurrentDictionary (System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (comparer As IEqualityComparer(Of TKey))

参数

comparer
IEqualityComparer<TKey>

在对键进行比较时使用的相等比较实现。

例外

comparernull

另请参阅

适用于

ConcurrentDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

初始化 类的新实例,该类 ConcurrentDictionary<TKey,TValue> 包含从指定的 IEnumerable 复制的元素具有默认并发级别,具有默认的初始容量,并使用指定的 IEqualityComparer<T>

public:
 ConcurrentDictionary(System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>> ^ collection, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public ConcurrentDictionary (System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection, System.Collections.Generic.IEqualityComparer<TKey> comparer);
public ConcurrentDictionary (System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : seq<System.Collections.Generic.KeyValuePair<'Key, 'Value>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)), comparer As IEqualityComparer(Of TKey))

参数

collection
IEnumerable<KeyValuePair<TKey,TValue>>

IEnumerable<T>,它的元素被复制到新 ConcurrentDictionary<TKey,TValue>

comparer
IEqualityComparer<TKey>

在对键进行比较时使用的 IEqualityComparer<T> 实现。

例外

collectioncomparernull

另请参阅

适用于

ConcurrentDictionary<TKey,TValue>(Int32, Int32)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例为空,具有指定的并发级别和容量,并为键类型使用默认比较器。

public:
 ConcurrentDictionary(int concurrencyLevel, int capacity);
public ConcurrentDictionary (int concurrencyLevel, int capacity);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : int * int -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (concurrencyLevel As Integer, capacity As Integer)

参数

concurrencyLevel
Int32

将同时更新 ConcurrentDictionary<TKey,TValue> 的估计线程数,或仅在 .NET 8+ 中更新 -1,以指示默认并发级别。

capacity
Int32

ConcurrentDictionary<TKey,TValue> 可包含的初始元素数。

例外

concurrencyLevel 小于 1。

capacity 小于 0。

另请参阅

适用于

ConcurrentDictionary<TKey,TValue>(Int32, IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例包含从指定的 IEnumerable 中复制的元素并使用指定的 IEqualityComparer<T>

public:
 ConcurrentDictionary(int concurrencyLevel, System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>> ^ collection, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public ConcurrentDictionary (int concurrencyLevel, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection, System.Collections.Generic.IEqualityComparer<TKey> comparer);
public ConcurrentDictionary (int concurrencyLevel, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : int * seq<System.Collections.Generic.KeyValuePair<'Key, 'Value>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (concurrencyLevel As Integer, collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)), comparer As IEqualityComparer(Of TKey))

参数

concurrencyLevel
Int32

将同时更新 ConcurrentDictionary<TKey,TValue> 的估计线程数,或仅在 .NET 8+ 中更新 -1,以指示默认并发级别。

collection
IEnumerable<KeyValuePair<TKey,TValue>>

IEnumerable<T>,它的元素被复制到新 ConcurrentDictionary<TKey,TValue>

comparer
IEqualityComparer<TKey>

在对键进行比较时使用的 IEqualityComparer<T> 实现。

例外

collectioncomparernull

concurrencyLevel 小于 1。

collection 包含一个或多个重复键。

另请参阅

适用于

ConcurrentDictionary<TKey,TValue>(Int32, Int32, IEqualityComparer<TKey>)

Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs
Source:
ConcurrentDictionary.cs

初始化 ConcurrentDictionary<TKey,TValue> 类的新实例,该实例为空,具有指定的并发级别和指定的初始容量,并使用指定的 IEqualityComparer<T>

public:
 ConcurrentDictionary(int concurrencyLevel, int capacity, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public ConcurrentDictionary (int concurrencyLevel, int capacity, System.Collections.Generic.IEqualityComparer<TKey> comparer);
public ConcurrentDictionary (int concurrencyLevel, int capacity, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value> : int * int * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value>
Public Sub New (concurrencyLevel As Integer, capacity As Integer, comparer As IEqualityComparer(Of TKey))

参数

concurrencyLevel
Int32

将同时更新 ConcurrentDictionary<TKey,TValue> 的估计线程数,或仅在 .NET 8+ 中更新 -1,以指示默认并发级别。

capacity
Int32

ConcurrentDictionary<TKey,TValue> 可包含的初始元素数。

comparer
IEqualityComparer<TKey>

在对键进行比较时使用的 IEqualityComparer<T> 实现。

例外

comparernull

concurrencyLevelcapacity 小于 1。

另请参阅

适用于