From f63dbffee37b37f641cf6a4b5aeb5d11665409c4 Mon Sep 17 00:00:00 2001 From: Archi Date: Wed, 21 Feb 2024 13:08:32 +0100 Subject: [PATCH] Add extra constructors --- ArchiSteamFarm/Collections/ConcurrentHashSet.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ArchiSteamFarm/Collections/ConcurrentHashSet.cs b/ArchiSteamFarm/Collections/ConcurrentHashSet.cs index 4c09f02af..394cb0e54 100644 --- a/ArchiSteamFarm/Collections/ConcurrentHashSet.cs +++ b/ArchiSteamFarm/Collections/ConcurrentHashSet.cs @@ -39,12 +39,25 @@ public sealed class ConcurrentHashSet : IReadOnlySet, ISet where T : no public ConcurrentHashSet() => BackingCollection = new ConcurrentDictionary(); + public ConcurrentHashSet(IEnumerable collection) { + ArgumentNullException.ThrowIfNull(collection); + + BackingCollection = new ConcurrentDictionary(collection.Select(static item => new KeyValuePair(item, true))); + } + public ConcurrentHashSet(IEqualityComparer comparer) { ArgumentNullException.ThrowIfNull(comparer); BackingCollection = new ConcurrentDictionary(comparer); } + public ConcurrentHashSet(IEnumerable collection, IEqualityComparer comparer) { + ArgumentNullException.ThrowIfNull(collection); + ArgumentNullException.ThrowIfNull(comparer); + + BackingCollection = new ConcurrentDictionary(collection.Select(static item => new KeyValuePair(item, true)), comparer); + } + public bool Add(T item) { ArgumentNullException.ThrowIfNull(item);