Class ConcurrentSet<T>
A concurrent, simplified HashSet.
Inherited Members
Namespace: Makaretu.Dns.Resolving
Assembly: Makaretu.Dns.dll
Syntax
public sealed class ConcurrentSet<T> : ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T |
Remarks
This is a copy and paste of https://github.com/dotnet/roslyn/blob/master/src/Compilers/Core/Portable/InternalUtilities/ConcurrentSet.cs taken on 18 July 2018.
Constructors
| Improve this Doc View SourceConcurrentSet()
Construct a concurrent set with the default concurrency level.
Declaration
public ConcurrentSet()
ConcurrentSet(IEnumerable<T>)
Construct a concurrent set using the specified the sequence.
Declaration
public ConcurrentSet(IEnumerable<T> values)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | values |
ConcurrentSet(IEqualityComparer<T>)
Construct a concurrent set 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
| Improve this Doc View SourceCount
Obtain the number of elements in the set.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 | The number of elements in the set. |
IsEmpty
Determine whether the set is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the set is empty; otherwise, false. |
IsReadOnly
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc 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 |
---|---|
Boolean | true if the value was added to the set. If the value already exists, this method returns false. |
AddRange(IEnumerable<T>)
Add a sequence to the set.
Declaration
public void AddRange(IEnumerable<T> values)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | values |
Clear()
Clear the set
Declaration
public void Clear()
Contains(T)
Determine whether the given value is in the set.
Declaration
public bool Contains(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to test. |
Returns
Type | Description |
---|---|
Boolean | true if the set contains the specified value; otherwise, false. |
CopyTo(T[], Int32)
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | |
Int32 | arrayIndex |
GetEnumerator()
Obtain an enumerator that iterates through the elements in the set.
Declaration
public ConcurrentSet<T>.KeyEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
ConcurrentSet.KeyEnumerator<> | An enumerator for the set. |
Remove(T)
Attempts to remove a value from the set.
Declaration
public bool Remove(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to remove. |
Returns
Type | Description |
---|---|
Boolean | true if the value was removed successfully; otherwise false. |
Explicit Interface Implementations
| Improve this Doc View SourceICollection<T>.Add(T)
Declaration
void ICollection<T>.Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
IEnumerable<T>.GetEnumerator()
Declaration
IEnumerator<T> IEnumerable<T>.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator |