Class ConcurrentSet<T>
This is a simple wrapper over ConcurrentDictionary<TKey, TValue>,
to provide an interface as a Set
(.NET does not provide a built-in concurrent hashset type)
for more consistent.
public class ConcurrentSet<T> : ICollection<T>, IEnumerable<T>, IEnumerable where T : notnull
Type Parameters
T
The type of elements in the set.
- Inheritance
-
ConcurrentSet<T>
- Implements
-
ICollection<T>IEnumerable<T>
- Inherited Members
Constructors
ConcurrentSet()
Initializes a new instance of the ConcurrentSet<T> class.
public ConcurrentSet()
Properties
Count
public int Count { get; }
Property Value
IsReadOnly
public bool IsReadOnly { get; }
Property Value
Methods
Add(T)
Adds the specified element to a set.
public bool Add(T item)
Parameters
item
TThe element to add to the set.
Returns
- bool
true
if the element is added to the ConcurrentSet<T> object;false
if the element is already present.
Clear()
public void Clear()
Contains(T)
public bool Contains(T item)
Parameters
item
T
Returns
CopyTo(T[], int)
public void CopyTo(T[] array, int arrayIndex)
Parameters
array
T[]arrayIndex
int
GetEnumerator()
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
Remove(T)
public bool Remove(T item)
Parameters
item
T