docs.unity3d.com
    Show / Hide Table of Contents

    Class HashSetList<T>

    Wrapper data structure for hashset, that leans on a list for deterministic sort order

    Inheritance
    Object
    HashSetList<T>
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.XR.CoreUtils.Collections
    Syntax
    public class HashSetList<T> : ISerializable, IDeserializationCallback, ISet<T>, ICollection<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
    Type Parameters
    Name Description
    T

    HashSetList type

    Constructors

    HashSetList(Int32)

    Allocates internal list and hashset.

    Declaration
    public HashSetList(int capacity = 0)
    Parameters
    Type Name Description
    Int32 capacity

    Initial list capacity

    Properties

    Count

    Internal list count.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32
    Implements
    ICollection<T>.Count
    IReadOnlyCollection<T>.Count

    Item[Int32]

    Access internal list element from index.

    Declaration
    public T this[int index] { get; }
    Parameters
    Type Name Description
    Int32 index

    Index used to access internal list.

    Property Value
    Type Description
    T

    Methods

    Add(T)

    Attempt to add item to internal hashset. If it is not already in the hashset, add it to the list.

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

    Item of type T to add.

    Returns
    Type Description
    Boolean

    True if the item was added to both list and hashset.

    Implements
    ISet<T>.Add(T)

    AsList()

    Exposes internal list without any allocation.

    Declaration
    public IReadOnlyList<T> AsList()
    Returns
    Type Description
    IReadOnlyList<T>

    Internal list structure.

    Clear()

    Clear both internal hashset and list.

    Declaration
    public void Clear()
    Implements
    ICollection<T>.Clear()

    Contains(T)

    Checks if internal hashset contains item.

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

    Item to check.

    Returns
    Type Description
    Boolean

    Returns true if internal hashset contains item, returns false otherwise.

    Implements
    ICollection<T>.Contains(T)

    CopyTo(T[], Int32)

    Copies out internal list as array.

    Declaration
    public void CopyTo(T[] array, int arrayIndex)
    Parameters
    Type Name Description
    T[] array

    Array to write to.

    Int32 arrayIndex

    Index to start from.

    Implements
    ICollection<T>.CopyTo(T[], Int32)

    ExceptWith(IEnumerable<T>)

    Except operation with hashset. Regenerates internal list from new hashset.

    Declaration
    public void ExceptWith(IEnumerable<T> other)
    Parameters
    Type Name Description
    IEnumerable<T> other

    Enumerable to except with.

    Implements
    ISet<T>.ExceptWith(IEnumerable<T>)

    GetEnumerator()

    Creates enumerator for internal list.

    Declaration
    public List<T>.Enumerator GetEnumerator()
    Returns
    Type Description
    List.Enumerator<>

    Returns internal list enumerator.

    GetObjectData(SerializationInfo, StreamingContext)

    Calls internal hashset GetObjectData and refreshes list.

    Declaration
    public void GetObjectData(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    SerializationInfo info

    GetObjectData info.

    StreamingContext context

    GetObjectData context.

    Implements
    ISerializable.GetObjectData(SerializationInfo, StreamingContext)

    IntersectWith(IEnumerable<T>)

    IntersectWith operation with hashset. Regenerates internal list from new hashset.

    Declaration
    public void IntersectWith(IEnumerable<T> other)
    Parameters
    Type Name Description
    IEnumerable<T> other

    Enumerable to intersect with.

    Implements
    ISet<T>.IntersectWith(IEnumerable<T>)

    IsProperSubsetOf(IEnumerable<T>)

    IsProperSubsetOf operation with hashset. Regenerates internal list from new hashset.

    Declaration
    public bool IsProperSubsetOf(IEnumerable<T> other)
    Parameters
    Type Name Description
    IEnumerable<T> other

    Enumerable to IsProperSubsetOf with.

    Returns
    Type Description
    Boolean

    Returns true if internal hashset is a proper subset of other, returns false otherwise.

    Implements
    ISet<T>.IsProperSubsetOf(IEnumerable<T>)

    IsProperSupersetOf(IEnumerable<T>)

    IsProperSupersetOf operation with hashset. Regenerates internal list from new hashset.

    Declaration
    public bool IsProperSupersetOf(IEnumerable<T> other)
    Parameters
    Type Name Description
    IEnumerable<T> other

    Enumerable to IsProperSupersetOf with.

    Returns
    Type Description
    Boolean

    Returns true if internal hashset is a proper superset of other, returns false otherwise.

    Implements
    ISet<T>.IsProperSupersetOf(IEnumerable<T>)

    IsSubsetOf(IEnumerable<T>)

    IsSubsetOf operation with hashset. Regenerates internal list from new hashset.

    Declaration
    public bool IsSubsetOf(IEnumerable<T> other)
    Parameters
    Type Name Description
    IEnumerable<T> other

    Enumerable to IsSubsetOf with.

    Returns
    Type Description
    Boolean

    Returns true if internal hashset is a subset of other, returns false otherwise.

    Implements
    ISet<T>.IsSubsetOf(IEnumerable<T>)

    IsSupersetOf(IEnumerable<T>)

    IsSupersetOf operation with hashset. Regenerates internal list from new hashset.

    Declaration
    public bool IsSupersetOf(IEnumerable<T> other)
    Parameters
    Type Name Description
    IEnumerable<T> other

    Enumerable to IsSupersetOf with.

    Returns
    Type Description
    Boolean

    Returns true if internal hashset is a superset of other, returns false.

    Implements
    ISet<T>.IsSupersetOf(IEnumerable<T>)

    OnDeserialization(Object)

    Deserializes sender object into internal hashset and refreshes list.

    Declaration
    public void OnDeserialization(object sender)
    Parameters
    Type Name Description
    Object sender

    Object to be deserialized as set.

    Implements
    IDeserializationCallback.OnDeserialization(Object)

    Overlaps(IEnumerable<T>)

    Overlaps operation with hashset.

    Declaration
    public bool Overlaps(IEnumerable<T> other)
    Parameters
    Type Name Description
    IEnumerable<T> other

    Enumerable to Overlaps with.

    Returns
    Type Description
    Boolean

    Returns true if there is overlap, returns false.

    Implements
    ISet<T>.Overlaps(IEnumerable<T>)

    Remove(T)

    Attempt to remove item to internal hashset. If it is still present in the hashset, remove it from the list.

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

    Item to remove.

    Returns
    Type Description
    Boolean

    True if the item was removed from both list and hashset.

    Implements
    ICollection<T>.Remove(T)

    SetEquals(IEnumerable<T>)

    Check if set equals other Overlaps(IEnumerable<T>) operation with hashset.

    Declaration
    public bool SetEquals(IEnumerable<T> other)
    Parameters
    Type Name Description
    IEnumerable<T> other

    Enumerable to Overlaps(IEnumerable<T>) with.

    Returns
    Type Description
    Boolean

    Returns true if hash iOverlaps operation is true, returns false otherwise.

    Implements
    ISet<T>.SetEquals(IEnumerable<T>)

    SymmetricExceptWith(IEnumerable<T>)

    SymmetricExceptWith between internal hashset and other IEnumerable. Refresh List.

    Declaration
    public void SymmetricExceptWith(IEnumerable<T> other)
    Parameters
    Type Name Description
    IEnumerable<T> other

    Enumerable to SymmetricExceptWith with.

    Implements
    ISet<T>.SymmetricExceptWith(IEnumerable<T>)

    UnionWith(IEnumerable<T>)

    UnionWith between internal hashset and other IEnumerable. Refresh List.

    Declaration
    public void UnionWith(IEnumerable<T> other)
    Parameters
    Type Name Description
    IEnumerable<T> other

    Enumerable to union with.

    Implements
    ISet<T>.UnionWith(IEnumerable<T>)

    Explicit Interface Implementations

    ICollection<T>.Add(T)

    Adds item to the existing internal list.

    Declaration
    void ICollection<T>.Add(T item)
    Parameters
    Type Name Description
    T item

    Item of type T to add.

    Implements
    ICollection<T>.Add(T)

    ICollection<T>.IsReadOnly

    Mandatory field. Always false.

    Declaration
    bool ICollection<T>.IsReadOnly { get; }
    Returns
    Type Description
    Boolean
    Implements
    ICollection<T>.IsReadOnly

    IEnumerable<T>.GetEnumerator()

    Gets an IEnumerator<T> for the internal list.

    Declaration
    IEnumerator<T> IEnumerable<T>.GetEnumerator()
    Returns
    Type Description
    IEnumerator<T>

    Returns internal list enumerator.

    Implements
    IEnumerable<T>.GetEnumerator()

    IEnumerable.GetEnumerator()

    Returns a standard enumerator that iterates through the collection.

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    IEnumerator

    An IEnumerator object that can be used to iterate through the collection.

    Implements
    IEnumerable.GetEnumerator()

    Extension Methods

    CollectionExtensions.Stringify<T>(ICollection<T>)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023