# NativeParallelHashMap<TKey, TValue>

> An unordered, expandable associative array.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule
* **Implements:** [INativeDisposable](/engine/6000.7/script-reference/unity/collections/inativedisposable.md), [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable), [IEnumerable\<KeyValue\<T, T>>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable)

```csharp
public struct NativeParallelHashMap<TKey, TValue> : INativeDisposable, IDisposable, IEnumerable<KeyValue<TKey, TValue>>, IEnumerable where TKey : unmanaged, IEquatable<TKey> where TValue : unmanaged
```

## Static Fields

| Value                                                                                                  | Description                                                     |
| ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------- |
| [MaxCapacity](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/maxcapacity.md) | The maximum number of elements this type of container can hold. |

## Constructors

| Constructor                                                                                                                                                                   | Description                                                   |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| [NativeParallelHashMap\`2(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle)](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/ctor.md) | Initializes and returns an instance of NativeParallelHashMap. |

## Properties

| Property                                                                                           | Description                                                         |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| [Capacity](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/capacity.md)   | The number of key-value pairs that fit in the current allocation.   |
| [IsCreated](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/iscreated.md) | Whether this hash map has been allocated (and not yet deallocated). |
| [IsEmpty](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/isempty.md)     | Whether this hash map is empty.                                     |
| [this\[\]](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/item.md)       | Gets and sets values by key.                                        |

## Methods

| Method                                                                                                             | Description                                                                          |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| [Add](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/add.md)                             | Adds a new key-value pair.                                                           |
| [AsParallelWriter](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/asparallelwriter.md)   | Returns a parallel writer for this hash map.                                         |
| [AsReadOnly](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/asreadonly.md)               | Returns a readonly version of this NativeParallelHashMap instance.                   |
| [Clear](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/clear.md)                         | Removes all key-value pairs.                                                         |
| [ContainsKey](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/containskey.md)             | Returns true if a given key is present in this hash map.                             |
| [Count](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/count.md)                         | The current number of key-value pairs in this hash map.                              |
| [Dispose](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/dispose.md)                     | Releases all resources (memory and safety handles).                                  |
| [GetEnumerator](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/getenumerator.md)         | Returns an enumerator over the key-value pairs of this hash map.                     |
| [GetKeyArray](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/getkeyarray.md)             | Returns an array with a copy of all this hash map's keys (in no particular order).   |
| [GetKeyValueArrays](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/getkeyvaluearrays.md) | Returns a NativeKeyValueArrays with a copy of all this hash map's keys and values.   |
| [GetValueArray](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/getvaluearray.md)         | Returns an array with a copy of all this hash map's values (in no particular order). |
| [Remove](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/remove.md)                       | Removes a key-value pair.                                                            |
| [TryAdd](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/tryadd.md)                       | Adds a new key-value pair.                                                           |
| [TryGetValue](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/trygetvalue.md)             | Returns the value associated with a key.                                             |

## Structs

| Struct                                                                                                                                            | Description                                                                                          |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| [NativeParallelHashMap\<TKey, TValue>.Enumerator](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/enumerator.md)         | An enumerator over the key-value pairs of a hash map.                                                |
| [NativeParallelHashMap\<TKey, TValue>.ParallelWriter](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/parallelwriter.md) | A parallel writer for a NativeParallelHashMap.                                                       |
| [NativeParallelHashMap\<TKey, TValue>.ReadOnly](/engine/6000.7/script-reference/unity/collections/nativeparallelhashmap2/readonly.md)             | A read-only alias for the value of a NativeParallelHashMap. Does not have its own allocated storage. |
