wasSharp

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 40  →  ?path2? @ 39
/Collections/Specialized/ConcurrentHashSet.cs
@@ -9,67 +9,14 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Linq;
 
namespace wasSharp.Collections.Specialized
{
public static class ConcurrentHashSetExtensions
{
public static ConcurrentHashSet<T> ToConcurrentHashSet<T>(this IEnumerable<T> enumerable)
{
return new ConcurrentHashSet<T>(enumerable);
}
}
 
public class ConcurrentHashSet<T> : IDisposable, ICollection<T>, IEnumerable<T>, ISet<T>
{
private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
private readonly HashSet<T> _hashSet = null;
private IEnumerable<string> enumerable;
private readonly HashSet<T> _hashSet = new HashSet<T>();
 
public ConcurrentHashSet()
{
_lock.EnterWriteLock();
try
{
_hashSet = new HashSet<T>();
}
finally
{
if (_lock.IsWriteLockHeld) _lock.ExitWriteLock();
}
}
 
public ConcurrentHashSet(IEqualityComparer<T> stringComparer)
{
_lock.EnterWriteLock();
try
{
_hashSet = new HashSet<T>(stringComparer);
}
finally
{
if (_lock.IsWriteLockHeld) _lock.ExitWriteLock();
}
}
 
public ConcurrentHashSet(IEnumerable<T> enumerable)
{
_lock.EnterWriteLock();
try
{
_hashSet = new HashSet<T>();
foreach (var i in enumerable)
{
_hashSet.Add(i);
}
}
finally
{
if (_lock.IsWriteLockHeld) _lock.ExitWriteLock();
}
}
 
#region Implementation of ICollection<T>
 
public bool Add(T item)
@@ -124,19 +71,6 @@
}
}
 
public int RemoveWhere(Predicate<T> match)
{
_lock.EnterWriteLock();
try
{
return _hashSet.RemoveWhere(match);
}
finally
{
if (_lock.IsWriteLockHeld) _lock.ExitWriteLock();
}
}
 
public int Count
{
get