Struct UnsafeMultiHashMap<TKey, TValue> | Collections | 0.11.0-preview.17
docs.unity3d.com
    Show / Hide Table of Contents

    Struct UnsafeMultiHashMap<TKey, TValue>

    Unordered associative array, a collection of keys and values, without any thread safety check features. This container can store multiple values for every key.

    Namespace: Unity.Collections.LowLevel.Unsafe
    Syntax
    public struct UnsafeMultiHashMap<TKey, TValue> : IEnumerable<KeyValue<TKey, TValue>>, IEnumerable, 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

    UnsafeMultiHashMap(Int32, Allocator)

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

    Declaration
    public UnsafeMultiHashMap(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.

    IsEmpty

    Reports whether container is empty.

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

    True if this container empty.

    Methods

    Add(TKey, TValue)

    Add an element with the specified key and value into the container.

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

    The key of the element to add.

    TValue item

    The value of the element to add.

    AsParallelWriter()

    Returns parallel writer instance.

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

    Parallel writer instance.

    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.

    Count()

    The current number of items in the container.

    Declaration
    public int Count()
    Returns
    Type Description
    Int32

    The item count.

    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.

    GetEnumerator()

    Returns an IEnumerator interface for the container.

    Declaration
    public UnsafeMultiHashMap<TKey, TValue>.KeyValueEnumerator GetEnumerator()
    Returns
    Type Description
    UnsafeMultiHashMap.KeyValueEnumerator<>

    An IEnumerator interface for the container.

    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 UnsafeMultiHashMap<TKey, TValue>.Enumerator GetValuesForKey(TKey key)
    Parameters
    Type Name Description
    TKey key

    Key to enumerate values for.

    Returns
    Type Description
    UnsafeMultiHashMap.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 and value 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

    The value of the element to remove.

    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.

    In This Article
    • Constructors
      • UnsafeMultiHashMap(Int32, Allocator)
    • Properties
      • Capacity
      • IsCreated
      • IsEmpty
    • Methods
      • Add(TKey, TValue)
      • AsParallelWriter()
      • Clear()
      • ContainsKey(TKey)
      • Count()
      • CountValuesForKey(TKey)
      • Dispose()
      • Dispose(JobHandle)
      • GetEnumerator()
      • GetKeyArray(Allocator)
      • GetKeyValueArrays(Allocator)
      • GetValueArray(Allocator)
      • GetValuesForKey(TKey)
      • Remove(TKey)
      • Remove(NativeMultiHashMapIterator<TKey>)
      • Remove<TValueEQ>(TKey, TValueEQ)
      • SetValue(TValue, NativeMultiHashMapIterator<TKey>)
      • TryGetFirstValue(TKey, out TValue, out NativeMultiHashMapIterator<TKey>)
      • TryGetNextValue(out TValue, ref NativeMultiHashMapIterator<TKey>)
    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