Struct NativeMultiHashMap<TKey, TValue> | Collections | 0.6.0-preview.9
docs.unity3d.com
    Show / Hide Table of Contents

    Struct NativeMultiHashMap<TKey, TValue>

    Unordered associative array, a collection of keys and values. This container can store multiple values for every key.

    Namespace: Unity.Collections
    Syntax
    public struct NativeMultiHashMap<TKey, TValue> : IDisposable where TKey : struct, IEquatable<TKey> where TValue : struct
    Type Parameters
    Name Description
    TKey

    The type of the keys in the container.

    TValue

    The type of the values in the container.

    Constructors

    NativeMultiHashMap(Int32, Allocator)

    Constructs a new container with the specified initial capacity and type of memory allocation.

    Declaration
    public NativeMultiHashMap(int capacity, Allocator allocator)
    Parameters
    Type Name Description
    Int32 capacity

    The initial capacity of the container. If the list grows larger than its capacity, the internal array is copied to a new, larger array.

    Allocator allocator

    A member of the Unity.Collections.Allocator enumeration.

    Properties

    Capacity

    The number of items that can fit in the container.

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

    The number of items that the container can hold before it resizes its internal storage.

    Remarks

    Capacity specifies the number of items the container can currently hold. You can change Capacity to fit more or fewer items. Changing Capacity creates a new array of the specified size, copies the old array to the new one, and then deallocates the original array memory.

    IsCreated

    Reports whether memory for the container is allocated.

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

    True if this container object's internal storage has been allocated.

    Remarks

    Note that the container storage is not created if you use the default constructor. You must specify at least an allocation type to construct a usable container.

    Length

    The current number of items in the container.

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

    The item count.

    Methods

    Add(TKey, TValue)

    Add an element with the specified key and value into the container. If the key already exist an ArgumentException will be thrown.

    Declaration
    public void Add(TKey key, TValue item)
    Parameters
    Type Name Description
    TKey key

    The key of the element to add.

    TValue item

    AsParallelWriter()

    Returns parallel writer instance.

    Declaration
    public NativeMultiHashMap<TKey, TValue>.ParallelWriter AsParallelWriter()
    Returns
    Type Description
    NativeMultiHashMap.ParallelWriter<>

    Clear()

    Clears the container.

    Declaration
    public void Clear()
    Remarks

    Containers capacity remains unchanged.

    ContainsKey(TKey)

    Determines whether an key is in the container.

    Declaration
    public bool ContainsKey(TKey key)
    Parameters
    Type Name Description
    TKey key

    The key to locate in the container.

    Returns
    Type Description
    Boolean

    Returns true if the container contains the key.

    CountValuesForKey(TKey)

    Count number of values for specified key.

    Declaration
    public int CountValuesForKey(TKey key)
    Parameters
    Type Name Description
    TKey key

    The key to locate in the container.

    Returns
    Type Description
    Int32

    Dispose()

    Disposes of this multi-hashmap and deallocates its memory immediately.

    Declaration
    public void Dispose()

    Dispose(JobHandle)

    Safely disposes of this container and deallocates its memory when the jobs that use it have completed.

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

    The job handle or handles for any scheduled jobs that use this container.

    Returns
    Type Description
    JobHandle

    A new job handle containing the prior handles as well as the handle for the job that deletes the container.

    Remarks

    You can call this function dispose of the container immediately after scheduling the job. Pass the JobHandle returned by the Job.Schedule method using the jobHandle parameter so the job scheduler can dispose the container after all jobs using it have run.

    GetKeyArray(Allocator)

    Returns array populated with keys.

    Declaration
    public NativeArray<TKey> GetKeyArray(Allocator allocator)
    Parameters
    Type Name Description
    Allocator allocator

    A member of the Unity.Collections.Allocator enumeration.

    Returns
    Type Description
    NativeArray<TKey>

    Array of keys.

    GetKeyValueArrays(Allocator)

    Returns arrays populated with keys and values.

    Declaration
    public NativeKeyValueArrays<TKey, TValue> GetKeyValueArrays(Allocator allocator)
    Parameters
    Type Name Description
    Allocator allocator

    A member of the Unity.Collections.Allocator enumeration.

    Returns
    Type Description
    NativeKeyValueArrays<TKey, TValue>

    Array of keys-values.

    GetValueArray(Allocator)

    Returns array populated with values.

    Declaration
    public NativeArray<TValue> GetValueArray(Allocator allocator)
    Parameters
    Type Name Description
    Allocator allocator

    A member of the Unity.Collections.Allocator enumeration.

    Returns
    Type Description
    NativeArray<TValue>

    Array of values.

    GetValuesForKey(TKey)

    Returns an enumerator for key that iterates through a container.

    Declaration
    public NativeMultiHashMap<TKey, TValue>.Enumerator GetValuesForKey(TKey key)
    Parameters
    Type Name Description
    TKey key

    Key to enumerate values for.

    Returns
    Type Description
    NativeMultiHashMap.Enumerator<>

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

    Remove(TKey)

    Removes all elements with the specified key from the container.

    Declaration
    public int Remove(TKey key)
    Parameters
    Type Name Description
    TKey key

    The key of the element to remove.

    Returns
    Type Description
    Int32

    Returns number of removed items.

    Remove(NativeMultiHashMapIterator<TKey>)

    Removes all elements with the specified iterator the container.

    Declaration
    public void Remove(NativeMultiHashMapIterator<TKey> it)
    Parameters
    Type Name Description
    NativeMultiHashMapIterator<TKey> it

    Iterator pointing at value to remove.

    Remove<TValueEQ>(TKey, TValueEQ)

    Removes all elements with the specified key from the container.

    Declaration
    public void Remove<TValueEQ>(TKey key, TValueEQ value)
        where TValueEQ : struct, IEquatable<TValueEQ>
    Parameters
    Type Name Description
    TKey key

    The key of the element to remove.

    TValueEQ value
    Type Parameters
    Name Description
    TValueEQ

    SetValue(TValue, NativeMultiHashMapIterator<TKey>)

    Replace value at iterator.

    Declaration
    public bool SetValue(TValue item, NativeMultiHashMapIterator<TKey> it)
    Parameters
    Type Name Description
    TValue item

    Value.

    NativeMultiHashMapIterator<TKey> it

    Iterator

    Returns
    Type Description
    Boolean

    Returns true if value was sucessfuly replaced.

    TryGetFirstValue(TKey, out TValue, out NativeMultiHashMapIterator<TKey>)

    Retrieve iterator for the first value for the key.

    Declaration
    public bool TryGetFirstValue(TKey key, out TValue item, out NativeMultiHashMapIterator<TKey> it)
    Parameters
    Type Name Description
    TKey key

    The key.

    TValue item

    Output value.

    NativeMultiHashMapIterator<TKey> it

    Iterator.

    Returns
    Type Description
    Boolean

    Returns true if the container contains the key.

    TryGetNextValue(out TValue, ref NativeMultiHashMapIterator<TKey>)

    Retrieve iterator to the next value for the key.

    Declaration
    public bool TryGetNextValue(out TValue item, ref NativeMultiHashMapIterator<TKey> it)
    Parameters
    Type Name Description
    TValue item

    Output value.

    NativeMultiHashMapIterator<TKey> it

    Iterator.

    Returns
    Type Description
    Boolean

    Returns true if next value for the key is found.

    Extension Methods

    JobNativeMultiHashMapVisitKeyValue.Schedule<TJob, TKey, TValue>(TJob, NativeMultiHashMap<TKey, TValue>, Int32, JobHandle)
    JobNativeMultiHashMapVisitKeyMutableValue.Schedule<TJob, TKey, TValue>(TJob, NativeMultiHashMap<TKey, TValue>, Int32, JobHandle)
    JobUnsafeMultiHashMapVisitKeyValue.Schedule<TJob, TKey, TValue>(TJob, UnsafeMultiHashMap<TKey, TValue>, Int32, JobHandle)
    JobUnsafeMultiHashMapVisitKeyMutableValue.Schedule<TJob, TKey, TValue>(TJob, UnsafeMultiHashMap<TKey, TValue>, Int32, JobHandle)
    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