docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct UnsafeHashSet<T>

    An unordered, expandable set of unique values.

    Implements
    INativeDisposable
    Namespace: Unity.Collections.LowLevel.Unsafe
    Assembly: Unity.Collections.dll
    Syntax
    public struct UnsafeHashSet<T> : INativeDisposable where T : unmanaged, IEquatable<T>
    Type Parameters
    Name Description
    T

    The type of the values.

    Constructors

    UnsafeHashSet(int, AllocatorHandle)

    Initializes and returns an instance of NativeParallelHashSet.

    Declaration
    public UnsafeHashSet(int initialCapacity, AllocatorManager.AllocatorHandle allocator)
    Parameters
    Type Name Description
    int initialCapacity

    The number of values that should fit in the initial allocation.

    AllocatorManager.AllocatorHandle allocator

    The allocator to use.

    Properties

    Capacity

    The number of values that fit in the current allocation.

    Declaration
    public int Capacity { readonly get; set; }
    Property Value
    Type Description
    int

    The number of values that fit in the current allocation.

    Count

    Returns the current number of values in this set.

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

    The current number of values in this set.

    IsCreated

    Whether this set has been allocated (and not yet deallocated).

    Declaration
    public readonly bool IsCreated { get; }
    Property Value
    Type Description
    bool

    True if this set has been allocated (and not yet deallocated).

    IsEmpty

    Whether this set is empty.

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

    True if this set is empty or if the set has not been constructed.

    Methods

    Add(T)

    Adds a new value (unless it is already present).

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

    The value to add.

    Returns
    Type Description
    bool

    True if the value was not already present.

    AsReadOnly()

    Returns a readonly version of this UnsafeHashMap instance.

    Declaration
    public UnsafeHashSet<T>.ReadOnly AsReadOnly()
    Returns
    Type Description
    UnsafeHashSet<T>.ReadOnly

    ReadOnly instance for this.

    Remarks

    ReadOnly containers point to the same underlying data as the UnsafeHashMap it is made from.

    Clear()

    Removes all values.

    Declaration
    public void Clear()
    Remarks

    Does not change the capacity.

    Contains(T)

    Returns true if a particular value is present.

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

    The value to check for.

    Returns
    Type Description
    bool

    True if the value was present.

    Dispose()

    Releases all resources (memory and safety handles).

    Declaration
    public void Dispose()

    Dispose(JobHandle)

    Creates and schedules a job that will dispose this set.

    Declaration
    public JobHandle Dispose(JobHandle inputDeps)
    Parameters
    Type Name Description
    JobHandle inputDeps

    A job handle. The newly scheduled job will depend upon this handle.

    Returns
    Type Description
    JobHandle

    The handle of a new job that will dispose this set.

    GetEnumerator()

    Returns an enumerator over the values of this set.

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

    An enumerator over the values of this set.

    Remove(T)

    Removes a particular value.

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

    The value to remove.

    Returns
    Type Description
    bool

    True if the value was present.

    ToNativeArray(AllocatorHandle)

    Returns an array with a copy of this set's values (in no particular order).

    Declaration
    public NativeArray<T> ToNativeArray(AllocatorManager.AllocatorHandle allocator)
    Parameters
    Type Name Description
    AllocatorManager.AllocatorHandle allocator

    The allocator to use.

    Returns
    Type Description
    NativeArray<T>

    An array with a copy of the set's values.

    TrimExcess()

    Sets the capacity to match what it would be if it had been originally initialized with all its entries.

    Declaration
    public void TrimExcess()

    Implements

    INativeDisposable

    Extension Methods

    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, FixedList128Bytes<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, FixedList32Bytes<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, FixedList4096Bytes<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, FixedList512Bytes<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, FixedList64Bytes<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, UnsafeHashSet<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, UnsafeHashSet<T>.ReadOnly)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, UnsafeList<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, UnsafeParallelHashSet<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, UnsafeParallelHashSet<T>.ReadOnly)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, NativeArray<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, NativeHashSet<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, NativeHashSet<T>.ReadOnly)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, NativeList<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, NativeParallelHashSet<T>)
    HashSetExtensions.ExceptWith<T>(ref UnsafeHashSet<T>, NativeParallelHashSet<T>.ReadOnly)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, FixedList128Bytes<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, FixedList32Bytes<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, FixedList4096Bytes<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, FixedList512Bytes<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, FixedList64Bytes<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, UnsafeHashSet<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, UnsafeHashSet<T>.ReadOnly)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, UnsafeList<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, UnsafeParallelHashSet<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, UnsafeParallelHashSet<T>.ReadOnly)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, NativeArray<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, NativeHashSet<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, NativeHashSet<T>.ReadOnly)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, NativeList<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, NativeParallelHashSet<T>)
    HashSetExtensions.IntersectWith<T>(ref UnsafeHashSet<T>, NativeParallelHashSet<T>.ReadOnly)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, FixedList128Bytes<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, FixedList32Bytes<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, FixedList4096Bytes<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, FixedList512Bytes<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, FixedList64Bytes<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, UnsafeHashSet<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, UnsafeHashSet<T>.ReadOnly)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, UnsafeList<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, UnsafeParallelHashSet<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, UnsafeParallelHashSet<T>.ReadOnly)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, NativeArray<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, NativeHashSet<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, NativeHashSet<T>.ReadOnly)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, NativeList<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, NativeParallelHashSet<T>)
    HashSetExtensions.UnionWith<T>(ref UnsafeHashSet<T>, NativeParallelHashSet<T>.ReadOnly)
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)