Table of Contents

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

T

The type of the values in the set.

Inheritance
object
ConcurrentSet<T>
Implements
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

collection IEnumerable<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

collection IEnumerable<T>

Elements to be copied to the new set.

comparer IEqualityComparer<T>

The IEqualityComparer<T> implementation to use when comparing elements.

ConcurrentSet(IEqualityComparer<T>)

Creates a new concurrent set.

public ConcurrentSet(IEqualityComparer<T> comparer)

Parameters

comparer IEqualityComparer<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

concurrencyLevel int

The estimated number of threads that will update the set concurrently

collection IEnumerable<T>

Elements to be copied to the new set.

comparer IEqualityComparer<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

concurrencyLevel int

The estimated number of threads that will update the set concurrently

capacity int

The initial number of elements that the set can contain.

Properties

Count

public int Count { get; }

Property Value

int

IsReadOnly

public bool IsReadOnly { get; }

Property Value

bool

Methods

Add(T)

public void Add(T item)

Parameters

item T

Clear()

public void Clear()

Contains(T)

public bool Contains(T item)

Parameters

item T

Returns

bool

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

Returns

bool