# NativeArraySharedInt

> Merge sort index list referencing NativeArray values.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule
* **Implements:** [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
public struct NativeArraySharedInt : IDisposable
```

## Remarks

Provide list of shared values, indices to shared values, and lists of source i value indices with identical shared value. As an example: Given Source NativeArray: \[A,A,A,B,B,C,C,A,B] Provides: Shared value indices: \[0,0,0,1,1,2,2,0,1] Shared value counts: \[4,3,2] (number of occurrences of a shared value) Shared values: \[A,B,C] (not stored in this structure) Sorted indices: \[0,1,2,7,3,4,8,5,6] (using these indices to look up values in the source array would give you \[A,A,A,A,B,B,B,C,C]) Shared value start offsets (into sorted indices): \[0,4,7]

## Constructors

| Constructor                                                                                                                                                                                          | Description                                                |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| [NativeArraySharedInt(Unity.Collections.NativeArray\{System.Int32},Unity.Collections.AllocatorManager.AllocatorHandle)](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/ctor.md) | Construct a NativeArraySharedInt struct from a NativeArray |

## Properties

| Property                                                                                                    | Description                                            |
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| [SharedValueCount](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/sharedvaluecount.md) | Number of shared (unique) values in source NativeArray |
| [SourceBuffer](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/sourcebuffer.md)         | Original Source Values (passed into constructor)       |

## Methods

| Method                                                                                                                                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Dispose](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/dispose.md)                                                             | Dispose this NativeArraySharedInt struct                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [GetSharedIndexArray](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/getsharedindexarray.md)                                     | Indices into shared values. For example, given source array: \[A,A,A,B,B,C,C,A,B] shared values are: \[A,B,C] shared index array would contain: \[0,0,0,1,1,2,2,0,1]                                                                                                                                                                                                                                                                                              |
| [GetSharedIndexBySourceIndex](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/getsharedindexbysourceindex.md)                     | Index of shared value associated with an element in the source buffer. For example, given source array: \[A,A,A,B,B,C,C,A,B] shared values are: \[A,B,C] Given the index 2 into the source array (A), the return value would be 0 (A in shared values).                                                                                                                                                                                                           |
| [GetSharedValueIndexCountArray](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/getsharedvalueindexcountarray.md)                 | Array of number of occurrences of all shared values. For example, given source array: \[A,A,A,B,B,C,C,A,B] shared values are: \[A,B,C] Shared value counts: \[4,3,2] (number of occurrences of a shared value)                                                                                                                                                                                                                                                    |
| [GetSharedValueIndexCountBySourceIndex](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/getsharedvalueindexcountbysourceindex.md) | Number of occurrences of a shared (unique) value shared by a given a source index. For example, given source array: \[A,A,A,B,B,C,C,A,B] shared values are: \[A,B,C] Shared value counts: \[4,3,2] (number of occurrences of a shared value) Given the index 2 into the source array (A), the return value would be 4 (for 4 occurrences of A in the source buffer).                                                                                              |
| [GetSharedValueIndicesBySharedIndex](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/getsharedvalueindicesbysharedindex.md)       | Array of indices into source NativeArray which share the same shared value For example, given source array: \[A,A,A,B,B,C,C,A,B] shared values are: \[A,B,C] Shared value counts: \[4,3,2] (number of occurrences of a shared value) Shared value start offsets (into sorted indices): \[0,4,7] Given the index 0 into the shared value array (A), the returned array would contain \[0,1,2,7] (indices into the source array which point to the shared value A). |
| [GetSharedValueIndicesBySourceIndex](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/getsharedvalueindicesbysourceindex.md)       | Array of indices into shared value indices NativeArray which share the same source value For example, given Source NativeArray: \[A,A,A,B,B,C,C,A,B] shared values are: \[A,B,C] Shared value indices: \[0,0,0,1,1,2,2,0,1] Given the index 2 into the source array (A), the returned array would contain: \[0,1,2,7] (indices in SharedValueIndices that have a value of 0, i.e. where A is in the shared values)                                                |
| [GetSortedIndices](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/getsortedindices.md)                                           | Indices into source NativeArray sorted by value                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [Schedule](/engine/7000.0/script-reference/unity/entities/nativearraysharedint/schedule.md)                                                           | Schedule jobs to collect and sort shared values.                                                                                                                                                                                                                                                                                                                                                                                                                  |
