# NativeParallelHashSet<T>

> An unordered, expandable set of unique values.

## 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\<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 NativeParallelHashSet<T> : INativeDisposable, IDisposable, IEnumerable<T>, IEnumerable where T : unmanaged, IEquatable<T>
```

## Static Fields

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

## Constructors

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

## Properties

| Property                                                                                           | Description                                                    |
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| [Capacity](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/capacity.md)   | The number of values that fit in the current allocation.       |
| [IsCreated](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/iscreated.md) | Whether this set has been allocated (and not yet deallocated). |
| [IsEmpty](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/isempty.md)     | Whether this set is empty.                                     |

## Methods

| Method                                                                                                           | Description                                                                                                                                                                     |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Add](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/add.md)                           | Adds a new item. If the item is already present in the collection, this method **should** throw, but currently does not! Instead, it returns false without replacing said item. |
| [AsParallelWriter](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/asparallelwriter.md) | Returns a parallel writer.                                                                                                                                                      |
| [AsReadOnly](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/asreadonly.md)             | Returns a readonly version of this NativeParallelHashSet instance.                                                                                                              |
| [Clear](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/clear.md)                       | Removes all values.                                                                                                                                                             |
| [Contains](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/contains.md)                 | Returns true if a particular value is present.                                                                                                                                  |
| [Count](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/count.md)                       | Returns the current number of values in this set.                                                                                                                               |
| [Dispose](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/dispose.md)                   | Releases all resources (memory and safety handles).                                                                                                                             |
| [GetEnumerator](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/getenumerator.md)       | Returns an enumerator over the values of this set.                                                                                                                              |
| [Remove](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/remove.md)                     | Removes a particular value.                                                                                                                                                     |
| [ToNativeArray](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/tonativearray.md)       | Returns an array with a copy of this set's values (in no particular order).                                                                                                     |
| [TryAdd](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/tryadd.md)                     | Attempts to add a new item. Only succeeds if the item was not present.                                                                                                          |

## Structs

| Struct                                                                                                                                 | Description                                                                                          |
| -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| [NativeParallelHashSet\<T>.Enumerator](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/enumerator.md)         | An enumerator over the values of a set.                                                              |
| [NativeParallelHashSet\<T>.ParallelWriter](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/parallelwriter.md) | A parallel writer for a NativeParallelHashSet.                                                       |
| [NativeParallelHashSet\<T>.ReadOnly](/engine/6000.7/script-reference/unity/collections/nativeparallelhashset1/readonly.md)             | A read-only alias for the value of a NativeParallelHashSet. Does not have its own allocated storage. |
