ThreadSafeDictionaryTKey, TValue(IEnumerableKeyValuePairTKey, TValue, IEqualityComparerTKey, HashingStrategy) Constructor

Initializes a new instance of the ThreadSafeDictionaryTKey, TValue class from the specified collection 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(
	IEnumerable<KeyValuePair<TKey, TValue>> collection,
	IEqualityComparer<TKey>? comparer = null,
	HashingStrategy strategy = HashingStrategy.Auto
)

Parameters

collection  IEnumerableKeyValuePairTKey, TValue
The collection whose elements are coped to the new ThreadSafeDictionaryTKey, TValue.
comparer  IEqualityComparerTKey  (Optional)
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