wabbajack/Wabbajack.Common/ConcurrentHashSet.cs
2020-05-14 16:21:56 -06:00

31 lines
658 B
C#

using System.Collections.Generic;
namespace Wabbajack.Common
{
public class ConcurrentHashSet<T> where T : notnull
{
private Dictionary<T, bool> _inner;
public ConcurrentHashSet()
{
_inner = new Dictionary<T, bool>();
}
public ConcurrentHashSet(IEnumerable<T> input)
{
_inner = new Dictionary<T, bool>();
foreach (var itm in input)
Add(itm);
}
public bool Contains(T key)
{
return _inner.ContainsKey(key);
}
public void Add(T key)
{
_inner[key] = true;
}
}
}