Show / Hide Table of Contents

    Class HashSet<T>

    A hash table implementation.

    Inheritance
    Object
    HashSet<T>
    Namespace: Advanced.Algorithms.DataStructures.Foundation
    Assembly: Advanced.Algorithms.dll
    Syntax
    public class HashSet<T> : IEnumerable<T>
    Type Parameters
    Name Description
    T

    The value datatype.

    Constructors

    HashSet(HashSetType, Int32)

    Declaration
    public HashSet(HashSetType type = HashSetType.SeparateChaining, int initialBucketSize = 2)
    Parameters
    Type Name Description
    HashSetType type

    The hashSet implementation to use.

    Int32 initialBucketSize

    The larger the bucket size lesser the collision, but memory matters!

    Properties

    Count

    The number of items in this hashset.

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

    Methods

    Add(T)

    Add a new value. Time complexity: O(1) amortized.

    Declaration
    public void Add(T value)
    Parameters
    Type Name Description
    T value

    The value to add.

    Clear()

    Clear the hashtable. Time complexity: O(1).

    Declaration
    public void Clear()

    Contains(T)

    Does this hash table contains the given value. Time complexity: O(1) amortized.

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

    The value to check.

    Returns
    Type Description
    Boolean

    True if this hashset contains the given value.

    GetEnumerator()

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

    Remove(T)

    Remove the given value. Time complexity: O(1) amortized.

    Declaration
    public void Remove(T value)
    Parameters
    Type Name Description
    T value

    The value to remove.

    Back to top Generated by DocFX