ConcurrentDictionary<TKey,TValue> ConcurrentDictionary<TKey,TValue> ConcurrentDictionary<TKey,TValue> ConcurrentDictionary<TKey,TValue> Constructors

定義

多載

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體是空的、具有預設並行層級、具有預設初始容量,並且使用索引鍵類型的預設比較子。Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體包含從指定的 IEnumerable<T> 複製的項目、具有預設的並行層級、預設的初始容量,並且使用索引鍵型別的預設比較子。Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable<T>, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體是空的、具有預設並行層級和容量,並且使用指定的 IEqualityComparer<T>Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the default concurrency level and capacity, and uses the specified IEqualityComparer<T>.

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體包含從指定的 IEnumerable 複製的項目、具有預設並行層級、具有預設初始容量,並且使用指定的 IEqualityComparer<T>Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable has the default concurrency level, has the default initial capacity, and uses the specified IEqualityComparer<T>.

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體是空的、具有指定的並行層級和容量,並且使用索引鍵類型的預設比較子。Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the specified concurrency level and capacity, and uses the default comparer for the key type.

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體包含從指定的 IEnumerable 複製的項目,且使用指定的 IEqualityComparer<T>Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable, and uses the specified IEqualityComparer<T>.

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體是空的、具有指定的並行層級、指定的初始容量,並且使用指定的 IEqualityComparer<T>Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the specified concurrency level, has the specified initial capacity, and uses the specified IEqualityComparer<T>.

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體是空的、具有預設並行層級、具有預設初始容量,並且使用索引鍵類型的預設比較子。Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

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

備註

預設並行層級等於 Cpu 的數目。The default concurrency level is equal to the number of CPUs. 並行層級愈高, 可能會在沒有干擾和封鎖的情況下進行更並行的寫入作業。The higher the concurrency level is, the more concurrent write operations can take place without interference and blocking. 較高的並行層級值也會導致需要所有鎖定的作業 (例如, ToArrayCount設大小的資料表和) 變得更昂貴。Higher concurrency level values also cause operations that require all locks (for example, table resizing, ToArray and Count) to become more expensive. 預設容量 (DEFAULT_CAPACITY) (代表值區的初始數目) 是非常小的字典大小和在建立大型字典時的調整大小之間的取捨。The default capacity (DEFAULT_CAPACITY), which represents the initial number of buckets, is a trade-off between the size of a very small dictionary and the number of resizes when constructing a large dictionary. 此外, 容量不應由小型質數整除。Also, the capacity should not be divisible by a small prime number. 預設容量為31。The default capacity is 31.

另請參閱

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體包含從指定的 IEnumerable<T> 複製的項目、具有預設的並行層級、預設的初始容量,並且使用索引鍵型別的預設比較子。Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable<T>, has the default concurrency level, has the default initial capacity, and uses the default comparer for the key type.

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>The IEnumerable<T> whose elements are copied to the new ConcurrentDictionary<TKey,TValue>.

例外狀況

collection 或其任何索引鍵為 nullcollection or any of its keys is null.

collection 包含一個或多個重複的索引鍵。collection contains one or more duplicate keys.

另請參閱

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體是空的、具有預設並行層級和容量,並且使用指定的 IEqualityComparer<T>Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the default concurrency level and capacity, and uses the specified IEqualityComparer<T>.

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>

比較索引鍵時所要使用的相等比較實作。The equality comparison implementation to use when comparing keys.

例外狀況

另請參閱

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體包含從指定的 IEnumerable 複製的項目、具有預設並行層級、具有預設初始容量,並且使用指定的 IEqualityComparer<T>Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable has the default concurrency level, has the default initial capacity, and uses the specified 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);
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>The IEnumerable<T> whose elements are copied to the new ConcurrentDictionary<TKey,TValue>.

comparer
IEqualityComparer<TKey>

比較索引鍵時所要使用的 IEqualityComparer<T> 實作。The IEqualityComparer<T> implementation to use when comparing keys.

例外狀況

collectioncomparernullcollection or comparer is null.

另請參閱

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體是空的、具有指定的並行層級和容量,並且使用索引鍵類型的預設比較子。Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the specified concurrency level and capacity, and uses the default comparer for the key type.

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 Int32 Int32 Int32

將同時更新 ConcurrentDictionary<TKey,TValue> 的預估執行緒數目。The estimated number of threads that will update the ConcurrentDictionary<TKey,TValue> concurrently.

capacity
Int32 Int32 Int32 Int32

ConcurrentDictionary<TKey,TValue> 可包含的初始項目數。The initial number of elements that the ConcurrentDictionary<TKey,TValue> can contain.

例外狀況

concurrencyLevel 小於 1。concurrencyLevel is less than 1.

-或--or- capacity 小於 0。capacity is less than 0.

另請參閱

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體包含從指定的 IEnumerable 複製的項目,且使用指定的 IEqualityComparer<T>Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that contains elements copied from the specified IEnumerable, and uses the specified 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);
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 Int32 Int32 Int32

將同時更新 ConcurrentDictionary<TKey,TValue> 的預估執行緒數目。The estimated number of threads that will update the ConcurrentDictionary<TKey,TValue> concurrently.

collection
IEnumerable<KeyValuePair<TKey,TValue>>

要將其項目複製到新 IEnumerable<T>ConcurrentDictionary<TKey,TValue>The IEnumerable<T> whose elements are copied to the new ConcurrentDictionary<TKey,TValue>.

comparer
IEqualityComparer<TKey>

比較索引鍵時所要使用的 IEqualityComparer<T> 實作。The IEqualityComparer<T> implementation to use when comparing keys.

例外狀況

collectioncomparernullcollection or comparer is null.

collection 包含一個或多個重複的索引鍵。collection contains one or more duplicate keys.

另請參閱

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

初始化 ConcurrentDictionary<TKey,TValue> 類別的新執行個體,這個執行個體是空的、具有指定的並行層級、指定的初始容量,並且使用指定的 IEqualityComparer<T>Initializes a new instance of the ConcurrentDictionary<TKey,TValue> class that is empty, has the specified concurrency level, has the specified initial capacity, and uses the specified 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);
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 Int32 Int32 Int32

將同時更新 ConcurrentDictionary<TKey,TValue> 的預估執行緒數目。The estimated number of threads that will update the ConcurrentDictionary<TKey,TValue> concurrently.

capacity
Int32 Int32 Int32 Int32

ConcurrentDictionary<TKey,TValue> 可包含的初始項目數。The initial number of elements that the ConcurrentDictionary<TKey,TValue> can contain.

comparer
IEqualityComparer<TKey>

比較索引鍵時所要使用的 IEqualityComparer<T> 實作。The IEqualityComparer<T> implementation to use when comparing keys.

例外狀況

concurrencyLevelcapacity 小於 1。concurrencyLevel or capacity is less than 1.

另請參閱

適用於