Class ConcurrentHashSet<T>
A thread-safe representation of a System.Collections.Generic.HashSet<T>. Enumerating this collection is thread-safe and will only operate on a clone that is generated before returning the enumerator.
Inheritance
Namespace: Umbraco.Cms.Core.Collections
Assembly: Umbraco.Core.dll
Syntax
[Serializable]
public class ConcurrentHashSet<T>
Type Parameters
| Name | Description |
|---|---|
| T |
Properties
View SourceCount
Gets the number of elements contained in the System.Collections.ICollection.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int | The number of elements contained in the System.Collections.ICollection. |
IsReadOnly
Gets a value indicating whether the System.Collections.Generic.ICollection<T> is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| bool | true if the System.Collections.Generic.ICollection<T> is read-only; otherwise, false. |
Methods
View SourceAdd(T)
Adds an item to the System.Collections.Generic.ICollection<T>.
Declaration
public void Add(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The object to add to the System.Collections.Generic.ICollection<T>. |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | The System.Collections.Generic.ICollection<T> is read-only. |
Clear()
Removes all items from the System.Collections.Generic.ICollection<T>.
Declaration
public void Clear()
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | The System.Collections.Generic.ICollection<T> is read-only. |
Contains(T)
Determines whether the System.Collections.Generic.ICollection<T> contains a specific value.
Declaration
public bool Contains(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The object to locate in the System.Collections.Generic.ICollection<T>. |
Returns
| Type | Description |
|---|---|
| bool | true if |
CopyTo(Array, int)
Copies the elements of the System.Collections.ICollection to an System.Array, starting at a particular System.Array index.
Declaration
public void CopyTo(Array array, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Array | array | The one-dimensional System.Array that is the destination of the elements copied from System.Collections.ICollection. The System.Array must have zero-based indexing. |
| int | index | The zero-based index in |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
| ArgumentException |
|
| ArgumentException | The type of the source System.Collections.ICollection
cannot be cast automatically to the type of the destination |
CopyTo(T[], int)
Copies the elements of the System.Collections.Concurrent.IProducerConsumerCollection<T> to an System.Array, starting at a specified index.
Declaration
public void CopyTo(T[] array, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | array | The one-dimensional System.Array that is the destination of the elements copied from the System.Collections.Concurrent.IProducerConsumerCollection<T>. The array must have zero-based indexing. |
| int | index | The zero-based index in |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
| ArgumentException |
|
ExceptWith(IEnumerable<T>)
Removes all elements in the specified collection from the current set.
Declaration
public void ExceptWith(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | other | The collection of items to remove from the set. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<T> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<T> | A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection. |
IntersectWith(IEnumerable<T>)
Modifies the current set so that it contains only elements that are also in a specified collection.
Declaration
public void IntersectWith(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | other | The collection to compare to the current set. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
IsProperSubsetOf(IEnumerable<T>)
Determines whether the current set is a proper (strict) subset of a specified collection.
Declaration
public bool IsProperSubsetOf(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| bool | true if the current set is a proper subset of |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
IsProperSupersetOf(IEnumerable<T>)
Determines whether the current set is a proper (strict) superset of a specified collection.
Declaration
public bool IsProperSupersetOf(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| bool | true if the current set is a proper superset of |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
IsSubsetOf(IEnumerable<T>)
Determines whether a set is a subset of a specified collection.
Declaration
public bool IsSubsetOf(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| bool | true if the current set is a subset of |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
IsSupersetOf(IEnumerable<T>)
Determines whether the current set is a superset of a specified collection.
Declaration
public bool IsSupersetOf(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| bool | true if the current set is a superset of |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
Overlaps(IEnumerable<T>)
Determines whether the current set overlaps with the specified collection.
Declaration
public bool Overlaps(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| bool | true if the current set and |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
Remove(T)
Removes the first occurrence of a specific object from the System.Collections.Generic.ICollection<T>.
Declaration
public bool Remove(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The object to remove from the System.Collections.Generic.ICollection<T>. |
Returns
| Type | Description |
|---|---|
| bool | true if |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | The System.Collections.Generic.ICollection<T> is read-only. |
SetEquals(IEnumerable<T>)
Determines whether the current set and the specified collection contain the same elements.
Declaration
public bool SetEquals(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | other | The collection to compare to the current set. |
Returns
| Type | Description |
|---|---|
| bool | true if the current set is equal to |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
SymmetricExceptWith(IEnumerable<T>)
Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both.
Declaration
public void SymmetricExceptWith(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | other | The collection to compare to the current set. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
TryAdd(T)
Attempts to add an item to the collection
Declaration
public bool TryAdd(T item)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item |
Returns
| Type | Description |
|---|---|
| bool |
UnionWith(IEnumerable<T>)
Modifies the current set so that it contains all elements that are present in the current set, in the specified collection, or in both.
Declaration
public void UnionWith(IEnumerable<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | other | The collection to compare to the current set. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|