wabbajack/Wabbajack.Common/ConcurrentHashSet.cs

31 lines
658 B
C#
Raw Normal View History

2020-05-14 22:21:56 +00:00
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;
}
}
}