Search Results for

    Show / Hide Table of Contents

    Class ConcurrentHashSet<T>

    Represents a thread-safe hash-based unique collection.

    Inheritance
    object
    ConcurrentHashSet<T>
    Implements
    IReadOnlyCollection<T>
    ICollection<T>
    IEnumerable<T>
    IEnumerable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Mapsui.Utilities
    Assembly: Mapsui.dll
    Syntax
    public class ConcurrentHashSet<T> : IReadOnlyCollection<T>, ICollection<T>, IEnumerable<T>, IEnumerable
    Type Parameters
    Name Description
    T

    The type of the items in the collection.

    Remarks

    All public members of ConcurrentHashSet<T> are thread-safe and may be used concurrently from multiple threads.

    Constructors

    | Edit this page View Source

    ConcurrentHashSet()

    Initializes a new instance of the ConcurrentHashSet<T> class that is empty, has the default concurrency level, has the default initial capacity, and uses the default comparer for the item type.

    Declaration
    public ConcurrentHashSet()
    | Edit this page View Source

    ConcurrentHashSet(IEnumerable<T>)

    Initializes a new instance of the ConcurrentHashSet<T> class that contains elements copied from the specified IEnumerable, has the default concurrency level, has the default initial capacity, and uses the default comparer for the item type.

    Declaration
    public ConcurrentHashSet(IEnumerable<T> collection)
    Parameters
    Type Name Description
    IEnumerable<T> collection

    The IEnumerable whose elements are copied to the new ConcurrentHashSet<T>.

    Exceptions
    Type Condition
    ArgumentNullException

    collection is a null reference.

    | Edit this page View Source

    ConcurrentHashSet(IEnumerable<T>, IEqualityComparer<T>?)

    Initializes a new instance of the ConcurrentHashSet<T> class that contains elements copied from the specified IEnumerable, has the default concurrency level, has the default initial capacity, and uses the specified System.Collections.Generic.IEqualityComparer{T}.

    Declaration
    public ConcurrentHashSet(IEnumerable<T> collection, IEqualityComparer<T>? comparer)
    Parameters
    Type Name Description
    IEnumerable<T> collection

    The IEnumerable whose elements are copied to the new ConcurrentHashSet<T>.

    IEqualityComparer<T> comparer

    The System.Collections.Generic.IEqualityComparer{T} implementation to use when comparing items.

    Exceptions
    Type Condition
    ArgumentNullException

    collection is a null reference (Nothing in Visual Basic).

    | Edit this page View Source

    ConcurrentHashSet(IEqualityComparer<T>?)

    Initializes a new instance of the ConcurrentHashSet<T> class that is empty, has the specified concurrency level and capacity, and uses the specified System.Collections.Generic.IEqualityComparer{T}.

    Declaration
    public ConcurrentHashSet(IEqualityComparer<T>? comparer)
    Parameters
    Type Name Description
    IEqualityComparer<T> comparer

    The System.Collections.Generic.IEqualityComparer{T} implementation to use when comparing items.

    | Edit this page View Source

    ConcurrentHashSet(int, IEnumerable<T>, IEqualityComparer<T>)

    Initializes a new instance of the ConcurrentHashSet<T> class that contains elements copied from the specified IEnumerable, has the specified concurrency level, has the specified initial capacity, and uses the specified System.Collections.Generic.IEqualityComparer{T}.

    Declaration
    public ConcurrentHashSet(int concurrencyLevel, IEnumerable<T> collection, IEqualityComparer<T> comparer)
    Parameters
    Type Name Description
    int concurrencyLevel

    The estimated number of threads that will update the ConcurrentHashSet<T> concurrently.

    IEnumerable<T> collection

    The IEnumerable whose elements are copied to the new ConcurrentHashSet<T>.

    IEqualityComparer<T> comparer

    The System.Collections.Generic.IEqualityComparer{T} implementation to use when comparing items.

    Exceptions
    Type Condition
    ArgumentNullException

    collection is a null reference.

    ArgumentOutOfRangeException

    concurrencyLevel is less than 1.

    | Edit this page View Source

    ConcurrentHashSet(int, int)

    Initializes a new instance of the ConcurrentHashSet<T> class that is empty, has the specified concurrency level and capacity, and uses the default comparer for the item type.

    Declaration
    public ConcurrentHashSet(int concurrencyLevel, int capacity)
    Parameters
    Type Name Description
    int concurrencyLevel

    The estimated number of threads that will update the ConcurrentHashSet<T> concurrently.

    int capacity

    The initial number of elements that the ConcurrentHashSet<T> can contain.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    concurrencyLevel is less than 1.

    ArgumentOutOfRangeException

    capacity is less than 0.

    | Edit this page View Source

    ConcurrentHashSet(int, int, IEqualityComparer<T>)

    Initializes a new instance of the ConcurrentHashSet<T> class that is empty, has the specified concurrency level, has the specified initial capacity, and uses the specified System.Collections.Generic.IEqualityComparer{T}.

    Declaration
    public ConcurrentHashSet(int concurrencyLevel, int capacity, IEqualityComparer<T> comparer)
    Parameters
    Type Name Description
    int concurrencyLevel

    The estimated number of threads that will update the ConcurrentHashSet<T> concurrently.

    int capacity

    The initial number of elements that the ConcurrentHashSet<T> can contain.

    IEqualityComparer<T> comparer

    The System.Collections.Generic.IEqualityComparer{T} implementation to use when comparing items.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    concurrencyLevel is less than 1. -or- capacity is less than 0.

    Properties

    | Edit this page View Source

    Count

    Gets the number of items contained in the ConcurrentHashSet<T>.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    int

    The number of items contained in the ConcurrentHashSet<T>.

    Remarks

    Count has snapshot semantics and represents the number of items in the ConcurrentHashSet<T> at the moment when Count was accessed.

    | Edit this page View Source

    IsEmpty

    Gets a value that indicates whether the ConcurrentHashSet<T> is empty.

    Declaration
    public bool IsEmpty { get; }
    Property Value
    Type Description
    bool

    true if the ConcurrentHashSet<T> is empty; otherwise, false.

    Methods

    | Edit this page View Source

    Add(T)

    Adds the specified item to the ConcurrentHashSet<T>.

    Declaration
    public bool Add(T item)
    Parameters
    Type Name Description
    T item

    The item to add.

    Returns
    Type Description
    bool

    true if the items was added to the ConcurrentHashSet<T> successfully; false if it already exists.

    Exceptions
    Type Condition
    OverflowException

    The ConcurrentHashSet<T> contains too many items.

    | Edit this page View Source

    Clear()

    Removes all items from the ConcurrentHashSet<T>.

    Declaration
    public void Clear()
    | Edit this page View Source

    Contains(T)

    Determines whether the ConcurrentHashSet<T> contains the specified item.

    Declaration
    public bool Contains(T item)
    Parameters
    Type Name Description
    T item

    The item to locate in the ConcurrentHashSet<T>.

    Returns
    Type Description
    bool

    true if the ConcurrentHashSet<T> contains the item; otherwise, false.

    | Edit this page View Source

    GetEnumerator()

    Returns an enumerator that iterates through the ConcurrentHashSet<T>.

    Declaration
    public IEnumerator<T> GetEnumerator()
    Returns
    Type Description
    IEnumerator<T>

    An enumerator for the ConcurrentHashSet<T>.

    Remarks

    The enumerator returned from the collection is safe to use concurrently with reads and writes to the collection, however it does not represent a moment-in-time snapshot of the collection. The contents exposed through the enumerator may contain modifications made to the collection after GetEnumerator() was called.

    | Edit this page View Source

    TryRemove(T)

    Attempts to remove the item from the ConcurrentHashSet<T>.

    Declaration
    public bool TryRemove(T item)
    Parameters
    Type Name Description
    T item

    The item to remove.

    Returns
    Type Description
    bool

    true if an item was removed successfully; otherwise, false.

    Implements

    IReadOnlyCollection<T>
    ICollection<T>
    IEnumerable<T>
    IEnumerable
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX