Struct NativeArraySharedValues<S>
Merge sort index list referencing NativeArray values. 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]
Namespace: Unity.Entities
Syntax
public struct NativeArraySharedValues<S> : IDisposable where S : struct, IComparable<S>
Type Parameters
Name | Description |
---|---|
S |
Constructors
NativeArraySharedValues(NativeArray<S>, Allocator)
Declaration
public NativeArraySharedValues(NativeArray<S> sourceBuffer, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<S> | sourceBuffer | |
Allocator | allocator |
Properties
SharedValueCount
Number of shared (unique) values in source NativeArray
Declaration
public readonly int SharedValueCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
SourceBuffer
Original Source Values (passed into constructor)
Declaration
public readonly NativeArray<S> SourceBuffer { get; }
Property Value
Type | Description |
---|---|
NativeArray<S> |
Methods
Dispose()
Declaration
public void Dispose()
GetSharedIndexArray()
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]
Declaration
public NativeArray<int> GetSharedIndexArray()
Returns
Type | Description |
---|---|
NativeArray<Int32> | Index NativeArray where each element refers to the index of a shared value in a list of shared (unique) values. |
GetSharedIndexBySourceIndex(Int32)
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).
Declaration
public int GetSharedIndexBySourceIndex(int indexIntoSourceBuffer)
Parameters
Type | Name | Description |
---|---|---|
Int32 | indexIntoSourceBuffer | Index of source value |
Returns
Type | Description |
---|---|
Int32 | Index into the list of shared values |
GetSharedValueIndexCountArray()
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)
Declaration
public NativeArray<int> GetSharedValueIndexCountArray()
Returns
Type | Description |
---|---|
NativeArray<Int32> | Count NativeArray where each element refers to the number of occurrences of each shared value. |
GetSharedValueIndexCountBySourceIndex(Int32)
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).
Declaration
public int GetSharedValueIndexCountBySourceIndex(int indexIntoSourceBuffer)
Parameters
Type | Name | Description |
---|---|---|
Int32 | indexIntoSourceBuffer | Index of source value. |
Returns
Type | Description |
---|---|
Int32 | Count of total occurrences of the shared value at a source buffer index in the source buffer. |
GetSharedValueIndicesBySharedIndex(Int32)
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).
Declaration
public NativeArray<int> GetSharedValueIndicesBySharedIndex(int sharedValueIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | sharedValueIndex | Index of shared value |
Returns
Type | Description |
---|---|
NativeArray<Int32> | Index NativeArray where each element refers to an index into the source array. |
GetSharedValueIndicesBySourceIndex(Int32)
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)
Declaration
public NativeArray<int> GetSharedValueIndicesBySourceIndex(int indexIntoSourceBuffer)
Parameters
Type | Name | Description |
---|---|---|
Int32 | indexIntoSourceBuffer | Index of source value |
Returns
Type | Description |
---|---|
NativeArray<Int32> | Index NativeArray where each element refers to an index into the shared value indices array. |
GetSortedIndices()
Indices into source NativeArray sorted by value
Declaration
public NativeArray<int> GetSortedIndices()
Returns
Type | Description |
---|---|
NativeArray<Int32> | Index NativeArray where each element refers to an element in the source NativeArray |
Schedule(JobHandle)
Schedule jobs to collect and sort shared values.
Declaration
public JobHandle Schedule(JobHandle inputDeps)
Parameters
Type | Name | Description |
---|---|---|
JobHandle | inputDeps | Dependent JobHandle |
Returns
Type | Description |
---|---|
JobHandle | JobHandle |