ThreadSafeDictionaryTKey, TValue(Int32, IEqualityComparerTKey, HashingStrategy) Constructor

Initializes a new instance of the ThreadSafeDictionaryTKey, TValue class that is empty and uses the specified comparer and hashing strategy.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
public ThreadSafeDictionary(
	int capacity,
	IEqualityComparer<TKey>? comparer,
	HashingStrategy strategy = HashingStrategy.Auto
)

Parameters

capacity  Int32
Specifies the initial minimum capacity of the internal temporal storage for values with new keys. If 0, then a default capacity is used.
comparer  IEqualityComparerTKey
The IEqualityComparerT implementation to use when comparing keys. If , EnumComparer<TEnum>.Comparer will be used for enum key types when targeting the .NET Framework, and EqualityComparer<T>.Default in other cases. This parameter is optional.
Default value: .
strategy  HashingStrategy  (Optional)
The hashing strategy to be used in the created ThreadSafeDictionaryTKey, TValue. This parameter is optional.
Default value: Auto.

Remarks

  Tip

If TKey is string and it is safe to use a non-randomized string comparer, then you can pass StringSegmentComparer.Ordinal to the comparer parameter for better performance.

See Also