Class ConcurrentSet<T>
A thread-safe set implementation using a ConcurrentDictionary<TKey, TValue>.
Inherited Members
Namespace: Akka.Util
Assembly: Akka.dll
Syntax
public class ConcurrentSet<T> : ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T | The type of elements in the set. |
Constructors
| Edit this page View SourceConcurrentSet()
Initializes a new, empty instance of the ConcurrentSet<T> class.
Declaration
public ConcurrentSet()
ConcurrentSet(IEnumerable<T>)
Initializes a new instance of the ConcurrentSet<T> class that contains elements copied from the specified collection.
Declaration
public ConcurrentSet(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The collection whose elements are copied to the new set. |
ConcurrentSet(IEnumerable<T>, IEqualityComparer<T>)
Initializes a new instance of the ConcurrentSet<T> class that contains elements copied from the specified collection and uses the specified equality comparer.
Declaration
public ConcurrentSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The collection whose elements are copied to the new set. |
IEqualityComparer<T> | comparer | The equality comparer to use for the set. |
ConcurrentSet(IEqualityComparer<T>)
Initializes a new, empty instance of the ConcurrentSet<T> class that uses the specified equality comparer.
Declaration
public ConcurrentSet(IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
IEqualityComparer<T> | comparer | The equality comparer to use for the set. |
ConcurrentSet(int, IEnumerable<T>, IEqualityComparer<T>)
Initializes a new instance of the ConcurrentSet<T> class that contains elements copied from the specified collection, has the specified concurrency level, and uses the specified equality comparer.
Declaration
public ConcurrentSet(int concurrencyLevel, IEnumerable<T> collection, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
int | concurrencyLevel | The estimated number of threads that will update the set concurrently. |
IEnumerable<T> | collection | The collection whose elements are copied to the new set. |
IEqualityComparer<T> | comparer | The equality comparer to use for the set. |
ConcurrentSet(int, int)
Initializes a new, empty instance of the ConcurrentSet<T> class with the specified concurrency level and capacity.
Declaration
public ConcurrentSet(int concurrencyLevel, int capacity)
Parameters
Type | Name | Description |
---|---|---|
int | concurrencyLevel | The estimated number of threads that will update the set concurrently. |
int | capacity | The initial number of elements that the set can contain. |
ConcurrentSet(int, int, IEqualityComparer<T>)
Initializes a new, empty instance of the ConcurrentSet<T> class with the specified concurrency level, capacity, and equality comparer.
Declaration
public ConcurrentSet(int concurrencyLevel, int capacity, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
int | concurrencyLevel | The estimated number of threads that will update the set concurrently. |
int | capacity | The initial number of elements that the set can contain. |
IEqualityComparer<T> | comparer | The equality comparer to use for the set. |
Properties
| Edit this page View SourceCount
Gets the number of elements contained in the set.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
IsEmpty
Gets a value indicating whether the set is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceClear()
Removes all elements from the set.
Declaration
public void Clear()
Contains(T)
Determines whether the set contains a specific value.
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The object to locate in the set. |
Returns
Type | Description |
---|---|
bool | true if the set contains the specified value; otherwise, false. |
TryAdd(T)
Attempts to add the specified element to the set.
Declaration
public bool TryAdd(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The element to add to the set. |
Returns
Type | Description |
---|---|
bool | true if the element is added to the set; false if the element is already present. |
TryRemove(T)
Attempts to remove and return the specified element from the set.
Declaration
public bool TryRemove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The element to remove. |
Returns
Type | Description |
---|---|
bool | true if the element is successfully removed; otherwise, false. |