Class ConcurrentSet<T>
- Namespace
- NanoByte.Common.Collections
- Assembly
- NanoByte.Common.dll
Represents a thread-safe set of values.
public class ConcurrentSet<T> : ICollection<T>, IEnumerable<T>, IEnumerable where T : notnull
Type Parameters
TThe type of the values in the set.
- Inheritance
-
objectConcurrentSet<T>
- Implements
-
ICollection<T>IEnumerable<T>
- Extension Methods
Remarks
This class is thread-safe.
Constructors
ConcurrentSet()
Creates a new concurrent set.
public ConcurrentSet()
ConcurrentSet(IEnumerable<T>)
Creates a new concurrent set.
public ConcurrentSet(IEnumerable<T> collection)
Parameters
collectionIEnumerable<T>Elements to be copied to the new set.
ConcurrentSet(IEnumerable<T>, IEqualityComparer<T>)
Creates a new concurrent set.
public ConcurrentSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
collectionIEnumerable<T>Elements to be copied to the new set.
comparerIEqualityComparer<T>The IEqualityComparer<T> implementation to use when comparing elements.
ConcurrentSet(IEqualityComparer<T>)
Creates a new concurrent set.
public ConcurrentSet(IEqualityComparer<T> comparer)
Parameters
comparerIEqualityComparer<T>The IEqualityComparer<T> implementation to use when comparing elements.
ConcurrentSet(int, IEnumerable<T>, IEqualityComparer<T>)
Creates a new concurrent set.
public ConcurrentSet(int concurrencyLevel, IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
concurrencyLevelintThe estimated number of threads that will update the set concurrently
collectionIEnumerable<T>Elements to be copied to the new set.
comparerIEqualityComparer<T>The IEqualityComparer<T> implementation to use when comparing values.
ConcurrentSet(int, int)
Creates a new concurrent set.
public ConcurrentSet(int concurrencyLevel, int capacity)
Parameters
concurrencyLevelintThe estimated number of threads that will update the set concurrently
capacityintThe initial number of elements that the set can contain.
Properties
Count
public int Count { get; }
Property Value
IsReadOnly
public bool IsReadOnly { get; }
Property Value
Methods
Add(T)
public void Add(T item)
Parameters
itemT
Clear()
public void Clear()
Contains(T)
public bool Contains(T item)
Parameters
itemT
Returns
CopyTo(T[], int)
public void CopyTo(T[] array, int arrayIndex)
Parameters
arrayT[]arrayIndexint
GetEnumerator()
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
Remove(T)
public bool Remove(T item)
Parameters
itemT