# NativeParallelMultiHashMap<TKey, TValue>

> An unordered, expandable associative array. Each key can have more than one associated value.

## 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 NativeParallelMultiHashMap<TKey, TValue> : INativeDisposable, IDisposable, IEnumerable<KeyValue<TKey, TValue>>, IEnumerable where TKey : unmanaged, IEquatable<TKey> where TValue : unmanaged
```

## Remarks

Unlike a regular NativeParallelHashMap, a NativeParallelMultiHashMap can store multiple key-value pairs with the same key.

The keys are not deduplicated: two key-value pairs with the same key are stored as fully separate key-value pairs.

## Static Fields

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

## Constructors

| Constructor                                                                                                                                                                             | Description                               |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| [NativeParallelMultiHashMap\`2(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle)](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/ctor.md) | Returns a newly allocated multi hash map. |

## Properties

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

## Methods

| Method                                                                                                                  | Description                                                                                     |
| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| [Add](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/add.md)                             | Adds a new key-value pair.                                                                      |
| [AsParallelWriter](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/asparallelwriter.md)   | Returns a parallel writer for this hash map.                                                    |
| [AsReadOnly](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/asreadonly.md)               | Returns a readonly version of this NativeParallelHashMap instance.                              |
| [Clear](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/clear.md)                         | Removes all key-value pairs.                                                                    |
| [ContainsKey](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/containskey.md)             | Returns true if a given key is present in this hash map.                                        |
| [Count](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/count.md)                         | Returns the current number of key-value pairs in this hash map.                                 |
| [CountValuesForKey](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/countvaluesforkey.md) | Returns the number of values associated with a given key.                                       |
| [Dispose](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/dispose.md)                     | Releases all resources (memory and safety handles).                                             |
| [GetEnumerator](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/getenumerator.md)         | Returns an enumerator over the key-value pairs of this hash map.                                |
| [GetKeyArray](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/getkeyarray.md)             | Returns an array with a copy of all the keys (in no particular order).                          |
| [GetKeyValueArrays](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/getkeyvaluearrays.md) | Returns a NativeKeyValueArrays with a copy of all the keys and values (in no particular order). |
| [GetValueArray](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/getvaluearray.md)         | Returns an array with a copy of all the values (in no particular order).                        |
| [GetValuesForKey](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/getvaluesforkey.md)     | Returns an enumerator over the values of an individual key.                                     |
| [Remove](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/remove.md)                       | Removes a key and its associated value(s).                                                      |
| [SetValue](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/setvalue.md)                   | Sets a new value for an existing key-value pair.                                                |
| [TryGetFirstValue](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/trygetfirstvalue.md)   | Gets an iterator for a key.                                                                     |
| [TryGetNextValue](/engine/6000.7/script-reference/unity/collections/nativeparallelmultihashmap2/trygetnextvalue.md)     | Advances an iterator to the next value associated with its key.                                 |

## Structs

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