Show / Hide Table of Contents

Class ConcurrentSet<T>

A concurrent, simplified HashSet.

Inheritance
object
ConcurrentSet<T>
Implements
ICollection<T>
IEnumerable<T>
IEnumerable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
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

https://github.com/dotnet/roslyn/blob/master/src/Compilers/Core/Portable/InternalUtilities/ConcurrentSet.cs

Constructors

View Source

ConcurrentSet()

Initializes a new instance of the ConcurrentSet<T> class with the default concurrency level.

Declaration
public ConcurrentSet()
View Source

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 Source

Count

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.

View Source

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.

View Source

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 Source

Add(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.

View Source

Clear()

Clear the set.

Declaration
public void Clear()
View Source

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.

View Source

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 array at which copying begins.

Exceptions
Type Condition
ArgumentNullException

array is null.

ArgumentOutOfRangeException

arrayIndex is less than 0.

ArgumentException

The number of elements in the source ICollection<T> is greater than the available space from arrayIndex to the end of the destination array.

View Source

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.

View Source

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.

Implements

ICollection<T>
IEnumerable<T>
IEnumerable

Extension Methods

ICollectionExtensions.GetNearestIndex<T>(ICollection<T>, int)
ICollectionExtensions.AddRange<T>(ICollection<T>, IEnumerable<T>)
ICollectionExtensions.ForEach<T>(ICollection<T>, Action<T>)
ICollectionExtensions.SetRange<T>(ICollection<T>, IEnumerable<T>)
IEnumerableExtensions.WithoutLast<T>(IEnumerable<T>)
  • View Source
In this article
Back to top Generated by DocFX