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

Definition

Overloads

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

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

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

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)

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

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

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>()

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 ()

Remarks

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. Higher concurrency level values also cause operations that require all locks (for example, table resizing, ToArray and Count) to become more expensive. 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. The default capacity is 31.

See Also

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

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)))
Parameters
collection
IEnumerable<KeyValuePair<TKey,TValue>>

The IEnumerable<T> whose elements are copied to the new ConcurrentDictionary<TKey,TValue>.

Exceptions

collection contains one or more duplicate keys.

See Also

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

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))
Parameters
comparer
IEqualityComparer<TKey>

The equality comparison implementation to use when comparing keys.

Exceptions
See Also

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

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))
Parameters
collection
IEnumerable<KeyValuePair<TKey,TValue>>

The IEnumerable<T> whose elements are copied to the new ConcurrentDictionary<TKey,TValue>.

comparer
IEqualityComparer<TKey>

The IEqualityComparer<T> implementation to use when comparing keys.

Exceptions
See Also

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

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)
Parameters
concurrencyLevel
Int32 Int32 Int32 Int32

The estimated number of threads that will update the ConcurrentDictionary<TKey,TValue> concurrently.

capacity
Int32 Int32 Int32 Int32

The initial number of elements that the ConcurrentDictionary<TKey,TValue> can contain.

Exceptions
See Also

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

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))
Parameters
concurrencyLevel
Int32 Int32 Int32 Int32

The estimated number of threads that will update the ConcurrentDictionary<TKey,TValue> concurrently.

collection
IEnumerable<KeyValuePair<TKey,TValue>>

The IEnumerable<T> whose elements are copied to the new ConcurrentDictionary<TKey,TValue>.

comparer
IEqualityComparer<TKey>

The IEqualityComparer<T> implementation to use when comparing keys.

Exceptions

collection contains one or more duplicate keys.

See Also

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

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))
Parameters
concurrencyLevel
Int32 Int32 Int32 Int32

The estimated number of threads that will update the ConcurrentDictionary<TKey,TValue> concurrently.

capacity
Int32 Int32 Int32 Int32

The initial number of elements that the ConcurrentDictionary<TKey,TValue> can contain.

comparer
IEqualityComparer<TKey>

The IEqualityComparer<T> implementation to use when comparing keys.

Exceptions
See Also

Applies to