Class ConcurrentSet<T>
Represents a thread-safe set of values.
Namespace: NanoByte.Common.Collections
Assembly: NanoByte.Common.dll
Syntax
public class ConcurrentSet<T> : Object
Type Parameters
Name | Description |
---|---|
T | The type of the values in the set. |
Remarks
This class is thread-safe.
Constructors
ConcurrentSet()
Creates a new concurrent set.
Declaration
public ConcurrentSet()
ConcurrentSet(IEnumerable<T>)
Creates a new concurrent set.
Declaration
public ConcurrentSet(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | Elements to be copied to the new set. |
ConcurrentSet(IEnumerable<T>, IEqualityComparer<T>)
Creates a new concurrent set.
Declaration
public ConcurrentSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | Elements to be copied to the new set. |
IEqualityComparer<T> | comparer | The IEqualityComparer<T> implementation to use when comparing elements. |
ConcurrentSet(IEqualityComparer<T>)
Creates a new concurrent set.
Declaration
public ConcurrentSet(IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
IEqualityComparer<T> | comparer | The IEqualityComparer<T> implementation to use when comparing elements. |
ConcurrentSet(Int32, IEnumerable<T>, IEqualityComparer<T>)
Creates a new concurrent set.
Declaration
public ConcurrentSet(int concurrencyLevel, IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
Int32 | concurrencyLevel | The estimated number of threads that will update the set concurrently |
IEnumerable<T> | collection | Elements to be copied to the new set. |
IEqualityComparer<T> | comparer | The IEqualityComparer<T> implementation to use when comparing values. |
ConcurrentSet(Int32, Int32)
Creates a new concurrent set.
Declaration
public ConcurrentSet(int concurrencyLevel, int capacity)
Parameters
Type | Name | Description |
---|---|---|
Int32 | concurrencyLevel | The estimated number of threads that will update the set concurrently |
Int32 | capacity | The initial number of elements that the set can contain. |
Properties
Count
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
IsReadOnly
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
Add(T)
Declaration
public void Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Clear()
Declaration
public void Clear()
Contains(T)
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
Boolean |
CopyTo(T[], Int32)
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | |
Int32 | arrayIndex |
GetEnumerator()
Declaration
public IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator |
Remove(T)
Declaration
public bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
Boolean |