Class ConcurrentSet<T>
A concurrent, simplified HashSet.
Inherited Members
Namespace: Microsoft.XboxStudios.BotBrain
Assembly: BotBrain.Core.dll
Syntax
public sealed class ConcurrentSet<T> : ICollection<T>, IEnumerable<T>, IEnumerable where T : notnull
Type Parameters
Name | Description |
---|---|
T | The item type. |
Remarks
Constructors
View SourceConcurrentSet()
Initializes a new instance of the ConcurrentSet<T> class with the default concurrency level.
Declaration
public ConcurrentSet()
ConcurrentSet(IEqualityComparer<T>)
Initializes a new instance of the ConcurrentSet<T> class using the specified equality comparer.
Declaration
public ConcurrentSet(IEqualityComparer<T> equalityComparer)
Parameters
Type | Name | Description |
---|---|---|
IEqualityComparer<T> | equalityComparer | The equality comparer for values in the set. |
Properties
View SourceCount
Gets the number of elements in the set.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int | The number of elements in the set. |
IsEmpty
Gets a value indicating whether the set is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool | true if the set is empty; otherwise, false. |
IsReadOnly
Gets a value indicating whether the ICollection<T> is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
bool | true if the ICollection<T> is read-only; otherwise, false. |
Methods
View SourceAdd(T)
Attempts to add a value to the set.
Declaration
public bool Add(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to add. |
Returns
Type | Description |
---|---|
bool | true if the value was added to the set. If the value already exists, this method returns false. |
Clear()
Clear the set.
Declaration
public void Clear()
Contains(T)
Determine whether the given value is in the set.
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to test. |
Returns
Type | Description |
---|---|
bool | true if the set contains the specified value; otherwise, false. |
CopyTo(T[], int)
Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing. |
int | arrayIndex | The zero-based index in |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
ArgumentException | The number of elements in the source ICollection<T> is greater than the available space from |
GetEnumerator()
Obtain an enumerator that iterates through the elements in the set.
Declaration
public ConcurrentSet<T>.KeyEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
ConcurrentSet<T>.KeyEnumerator | An enumerator for the set. |
Remove(T)
Attempts to remove a value from the set.
Declaration
public bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to remove. |
Returns
Type | Description |
---|---|
bool | true if the value was removed successfully; otherwise false. |