Struct NativeHashMap<TKey, TValue>
An unordered, expandable associative array.
Implements
Namespace: Unity.Collections
Assembly: solution.dll
Syntax
[NativeContainer]
public struct NativeHashMap<TKey, TValue> : INativeDisposable where TKey : unmanaged, IEquatable<TKey> where TValue : unmanaged
Type Parameters
Name | Description |
---|---|
TKey | The type of the keys. |
TValue | The type of the values. |
Remarks
Not suitable for parallel write access. Use Native
Constructors
Name | Description |
---|---|
Native |
Initializes and returns an instance of UnsafeHashMap. |
Properties
Name | Description |
---|---|
Capacity | The number of key-value pairs that fit in the current allocation. |
Count | The current number of key-value pairs in this hash map. |
Is |
Whether this hash map has been allocated (and not yet deallocated). |
Is |
Whether this hash map is empty. |
this[TKey] | Gets and sets values by key. |
Methods
Name | Description |
---|---|
Add(TKey, TValue) | Adds a new key-value pair. |
As |
Returns a readonly version of this NativeHashMap instance. |
Clear() | Removes all key-value pairs. |
Contains |
Returns true if a given key is present in this hash map. |
Dispose() | Releases all resources (memory). |
Dispose(Job |
Creates and schedules a job that will dispose this hash map. |
Get |
Returns an enumerator over the key-value pairs of this hash map. |
Get |
Returns an array with a copy of all this hash map's keys (in no particular order). |
Get |
Returns a NativeKeyValueArrays with a copy of all this hash map's keys and values. |
Get |
Returns an array with a copy of all this hash map's values (in no particular order). |
Remove(TKey) | Removes a key-value pair. |
Trim |
Sets the capacity to match what it would be if it had been originally initialized with all its entries. |
Try |
Adds a new key-value pair. |
Try |
Returns the value associated with a key. |