docs.unity.cn
    Show / Hide Table of Contents

    Struct NativeHashSet<T>

    An unordered, expandable set of unique values.

    Namespace: Unity.Collections
    Syntax
    public struct NativeHashSet<T> : INativeDisposable, IDisposable, IEnumerable<T>, IEnumerable where T : struct, IEquatable<T>
    Type Parameters
    Name Description
    T

    The type of the values.

    Constructors

    NativeHashSet(Int32, AllocatorManager.AllocatorHandle)

    Initializes and returns an instance of NativeHashSet.

    Declaration
    public NativeHashSet(int capacity, AllocatorManager.AllocatorHandle allocator)
    Parameters
    Type Name Description
    Int32 capacity

    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 { get; set; }
    Property Value
    Type Description
    Int32

    The number of values that fit in the current allocation.

    Exceptions
    Type Condition
    Exception

    Thrown if value is less than the current capacity.

    IsCreated

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

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

    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
    Boolean

    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
    Boolean

    True if the value was not already present.

    AsParallelWriter()

    Returns a parallel writer.

    Declaration
    public NativeHashSet<T>.ParallelWriter AsParallelWriter()
    Returns
    Type Description
    NativeHashSet.ParallelWriter<>

    A parallel writer.

    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
    Boolean

    True if the value was present.

    Count()

    Returns the current number of values in this set.

    Declaration
    public int Count()
    Returns
    Type Description
    Int32

    The current number of values in this set.

    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.

    Implements
    INativeDisposable.Dispose(JobHandle)

    GetEnumerator()

    Returns an enumerator over the values of this set.

    Declaration
    public NativeHashSet<T>.Enumerator GetEnumerator()
    Returns
    Type Description
    NativeHashSet.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
    Boolean

    True if the value was present.

    ToNativeArray(AllocatorManager.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.

    Extension Methods

    HashSetExtensions.ExceptWith<T>(NativeHashSet<T>, FixedList128Bytes<T>)
    HashSetExtensions.IntersectWith<T>(NativeHashSet<T>, FixedList128Bytes<T>)
    HashSetExtensions.UnionWith<T>(NativeHashSet<T>, FixedList128Bytes<T>)
    HashSetExtensions.ExceptWith<T>(NativeHashSet<T>, FixedList32Bytes<T>)
    HashSetExtensions.IntersectWith<T>(NativeHashSet<T>, FixedList32Bytes<T>)
    HashSetExtensions.UnionWith<T>(NativeHashSet<T>, FixedList32Bytes<T>)
    HashSetExtensions.ExceptWith<T>(NativeHashSet<T>, FixedList4096Bytes<T>)
    HashSetExtensions.IntersectWith<T>(NativeHashSet<T>, FixedList4096Bytes<T>)
    HashSetExtensions.UnionWith<T>(NativeHashSet<T>, FixedList4096Bytes<T>)
    HashSetExtensions.ExceptWith<T>(NativeHashSet<T>, FixedList512Bytes<T>)
    HashSetExtensions.IntersectWith<T>(NativeHashSet<T>, FixedList512Bytes<T>)
    HashSetExtensions.UnionWith<T>(NativeHashSet<T>, FixedList512Bytes<T>)
    HashSetExtensions.ExceptWith<T>(NativeHashSet<T>, FixedList64Bytes<T>)
    HashSetExtensions.IntersectWith<T>(NativeHashSet<T>, FixedList64Bytes<T>)
    HashSetExtensions.UnionWith<T>(NativeHashSet<T>, FixedList64Bytes<T>)
    HashSetExtensions.ExceptWith<T>(NativeHashSet<T>, NativeArray<T>)
    HashSetExtensions.IntersectWith<T>(NativeHashSet<T>, NativeArray<T>)
    HashSetExtensions.UnionWith<T>(NativeHashSet<T>, NativeArray<T>)
    HashSetExtensions.ExceptWith<T>(NativeHashSet<T>, NativeHashSet<T>)
    HashSetExtensions.IntersectWith<T>(NativeHashSet<T>, NativeHashSet<T>)
    HashSetExtensions.UnionWith<T>(NativeHashSet<T>, NativeHashSet<T>)
    HashSetExtensions.ExceptWith<T>(NativeHashSet<T>, NativeList<T>)
    HashSetExtensions.IntersectWith<T>(NativeHashSet<T>, NativeList<T>)
    HashSetExtensions.UnionWith<T>(NativeHashSet<T>, NativeList<T>)
    Extensions.ToArray<T>(NativeHashSet<T>)
    HashSetExtensions.ExceptWith<T>(NativeHashSet<T>, UnsafeHashSet<T>)
    HashSetExtensions.IntersectWith<T>(NativeHashSet<T>, UnsafeHashSet<T>)
    HashSetExtensions.UnionWith<T>(NativeHashSet<T>, UnsafeHashSet<T>)
    HashSetExtensions.ExceptWith<T>(NativeHashSet<T>, UnsafeList<T>)
    HashSetExtensions.IntersectWith<T>(NativeHashSet<T>, UnsafeList<T>)
    HashSetExtensions.UnionWith<T>(NativeHashSet<T>, UnsafeList<T>)
    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Tuesday, June 14, 2022
    Terms of use