NativeHashMap<TKey, TValue>
An unordered, expandable associative array.
Read time 2 minutesLast updated 6 days ago
Definition
- Type: Struct
- Namespace: Unity.Collections
- Assembly: UnityEngine.ManagedKernelModule
- Implements: INativeDisposable, IDisposable, IEnumerable<KVPair<T, T>>, IEnumerable
public struct NativeHashMap<TKey, TValue> : INativeDisposable, IDisposable, IEnumerable<KVPair<TKey, TValue>>, IEnumerable where TKey : unmanaged, IEquatable<TKey> where TValue : unmanaged
Remarks
Not suitable for parallel write access. Use NativeParallelHashMap<TKey, TValue> instead.
Static Fields
Value | Description |
|---|---|
| MaxCapacity | The maximum number of elements this type of container can hold. |
Constructors
Constructor | Description |
|---|---|
| NativeHashMap`2(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle) | Initializes and returns an instance of UnsafeHashMap. |
Properties
Property | 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. |
| IsCreated | Whether this hash map has been allocated (and not yet deallocated). |
| IsEmpty | Whether this hash map is empty. |
| this[] | Gets and sets values by key. |
Methods
Method | Description |
|---|---|
| Add | Adds a new key-value pair. |
| AsReadOnly | Returns a readonly version of this NativeHashMap instance. |
| Clear | Removes all key-value pairs. |
| ContainsKey | Returns true if a given key is present in this hash map. |
| Dispose | Releases all resources (memory). |
| GetEnumerator | Returns an enumerator over the key-value pairs of this hash map. |
| GetKeyArray | Returns an array with a copy of all this hash map's keys (in no particular order). |
| GetKeyValueArrays | Returns a NativeKeyValueArrays with a copy of all this hash map's keys and values. |
| GetValueArray | Returns an array with a copy of all this hash map's values (in no particular order). |
| Remove | Removes a key-value pair. |
| TrimExcess | Sets the capacity to match what it would be if it had been originally initialized with all its entries. |
| TryAdd | Adds a new key-value pair. |
| TryGetValue | Returns the value associated with a key. |
Structs
Struct | Description |
|---|---|
| NativeHashMap<TKey, TValue>.Enumerator | An enumerator over the key-value pairs of a container. |
| NativeHashMap<TKey, TValue>.ReadOnly | A read-only alias for the value of a NativeHashMap. Does not have its own allocated storage. |