Class CoreUnsafeUtils
Static class with unsafe utility functions.
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public static class CoreUnsafeUtils
Methods
CombineHashes(int, Hash128*, Hash128*)
Combine hashes.
Declaration
public static void CombineHashes(int count, Hash128* hashes, Hash128* outHash)
Parameters
Type | Name | Description |
---|---|---|
int | count | Number of hash to combine. |
Hash128* | hashes | Hashes to combine. |
Hash128* | outHash | Hash to update. |
CombineHashes<TValue, TGetter>(int, void*, Hash128*)
Combine all of the hashes of a collection of hashes.
Declaration
public static void CombineHashes<TValue, TGetter>(int count, void* hashes, Hash128* outHash) where TValue : struct where TGetter : struct, CoreUnsafeUtils.IKeyGetter<TValue, Hash128>
Parameters
Type | Name | Description |
---|---|---|
int | count | Number of hash to combine. |
void* | hashes | Hashes to combine. |
Hash128* | outHash | Hash to update. |
Type Parameters
Name | Description |
---|---|
TValue | Value type. |
TGetter | Getter type. |
CompareHashes(int, Hash128*, int, Hash128*, int*, int*, out int, out int)
Compare hashes.
Declaration
public static int CompareHashes(int oldHashCount, Hash128* oldHashes, int newHashCount, Hash128* newHashes, int* addIndices, int* removeIndices, out int addCount, out int remCount)
Parameters
Type | Name | Description |
---|---|---|
int | oldHashCount | Number of hashes in |
Hash128* | oldHashes | Previous hashes to compare. |
int | newHashCount | Number of hashes in |
Hash128* | newHashes | New hashes to compare. |
int* | addIndices | Indices of element to add in |
int* | removeIndices | Indices of element to remove in |
int | addCount | Number of elements to add will be written here. |
int | remCount | Number of elements to remove will be written here. |
Returns
Type | Description |
---|---|
int | The number of operation to perform ( )
|
CompareHashes<TOldValue, TOldGetter, TNewValue, TNewGetter>(int, void*, int, void*, int*, int*, out int, out int)
Compare hashes of two collections and provide
a list of indices removeIndices
to remove in oldHashes
and a list of indices addIndices
to add in newHashes
.
Assumes that newHashes
and oldHashes
are sorted.
Declaration
public static int CompareHashes<TOldValue, TOldGetter, TNewValue, TNewGetter>(int oldHashCount, void* oldHashes, int newHashCount, void* newHashes, int* addIndices, int* removeIndices, out int addCount, out int remCount) where TOldValue : struct where TOldGetter : struct, CoreUnsafeUtils.IKeyGetter<TOldValue, Hash128> where TNewValue : struct where TNewGetter : struct, CoreUnsafeUtils.IKeyGetter<TNewValue, Hash128>
Parameters
Type | Name | Description |
---|---|---|
int | oldHashCount | Number of hashes in |
void* | oldHashes | Previous hashes to compare. |
int | newHashCount | Number of hashes in |
void* | newHashes | New hashes to compare. |
int* | addIndices | Indices of element to add in |
int* | removeIndices | Indices of element to remove in |
int | addCount | Number of elements to add will be written here. |
int | remCount | Number of elements to remove will be written here. |
Returns
Type | Description |
---|---|
int | The number of operation to perform ( )
|
Type Parameters
Name | Description |
---|---|
TOldValue | Old value type. |
TOldGetter | Old getter type. |
TNewValue | New value type. |
TNewGetter | New getter type. |
CopyTo<T>(List<T>, void*, int)
Extension method to copy elements of a list into a buffer.
Declaration
public static void CopyTo<T>(this List<T> list, void* dest, int count) where T : struct
Parameters
Type | Name | Description |
---|---|---|
List<T> | list | Input List. |
void* | dest | Destination buffer. |
int | count | Number of elements to copy. |
Type Parameters
Name | Description |
---|---|
T | Type of the provided List. |
CopyTo<T>(T[], void*, int)
Extension method to copy elements of an array into a buffer.
Declaration
public static void CopyTo<T>(this T[] list, void* dest, int count) where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | list | Input List. |
void* | dest | Destination buffer. |
int | count | Number of elements to copy. |
Type Parameters
Name | Description |
---|---|
T | Type of the provided array. |
HaveDuplicates(int[])
Checks for duplicates in an array.
Declaration
public static bool HaveDuplicates(int[] arr)
Parameters
Type | Name | Description |
---|---|---|
int[] | arr | Input array. |
Returns
Type | Description |
---|---|
bool | True if there is any duplicate in the input array. |
IndexOf<T>(void*, int, T)
Index of an element in a buffer.
Declaration
public static int IndexOf<T>(void* data, int count, T v) where T : struct, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
void* | data | Data buffer. |
int | count | Number of elements. |
T | v | Element to test against. |
Returns
Type | Description |
---|---|
int | The first index of the provided element. |
Type Parameters
Name | Description |
---|---|
T | Data type. |
InsertionSort(uint[], int)
Insertion sort
Declaration
public static void InsertionSort(uint[] arr, int sortSize)
Parameters
Type | Name | Description |
---|---|---|
uint[] | arr | Array to sort. |
int | sortSize | Size of the array to sort. If greater than array capacity, it will get clamped. |
InsertionSort(NativeArray<uint>, int)
Insertion sort
Declaration
public static void InsertionSort(NativeArray<uint> arr, int sortSize)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<uint> | arr | Array to sort. |
int | sortSize | Size of the array to sort. If greater than array capacity, it will get clamped. |
MergeSort(uint[], int, ref uint[])
Merge sort - non recursive
Declaration
public static void MergeSort(uint[] arr, int sortSize, ref uint[] supportArray)
Parameters
Type | Name | Description |
---|---|---|
uint[] | arr | Array to sort. |
int | sortSize | Size of the array to sort. If greater than array capacity, it will get clamped. |
uint[] | supportArray | Secondary array reference, used to store intermediate merge results. |
MergeSort(NativeArray<uint>, int, ref NativeArray<uint>)
Merge sort - non recursive
Declaration
public static void MergeSort(NativeArray<uint> arr, int sortSize, ref NativeArray<uint> supportArray)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<uint> | arr | Array to sort. |
int | sortSize | Size of the array to sort. If greater than array capacity, it will get clamped. |
NativeArray<uint> | supportArray | Secondary array reference, used to store intermediate merge results. |
QuickSort(uint[], int, int)
Quick Sort
Declaration
public static void QuickSort(uint[] arr, int left, int right)
Parameters
Type | Name | Description |
---|---|---|
uint[] | arr | uint array. |
int | left | Left boundary. |
int | right | Left boundary. |
QuickSort<T>(int, void*)
Quick sort.
Declaration
public static void QuickSort<T>(int count, void* data) where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
int | count | Number of element. |
void* | data | Buffer to sort. |
Type Parameters
Name | Description |
---|---|
T | Type to compare. |
QuickSort<TValue, TKey, TGetter>(int, void*)
Quick sort.
Declaration
public static void QuickSort<TValue, TKey, TGetter>(int count, void* data) where TValue : struct where TKey : struct, IComparable<TKey> where TGetter : struct, CoreUnsafeUtils.IKeyGetter<TValue, TKey>
Parameters
Type | Name | Description |
---|---|---|
int | count | Number of element. |
void* | data | Data to sort. |
Type Parameters
Name | Description |
---|---|
TValue | Value type. |
TKey | Key Type. |
TGetter | Getter type. |
QuickSort<TValue, TKey, TGetter>(void*, int, int)
Quick sort.
Declaration
public static void QuickSort<TValue, TKey, TGetter>(void* data, int left, int right) where TValue : struct where TKey : struct, IComparable<TKey> where TGetter : struct, CoreUnsafeUtils.IKeyGetter<TValue, TKey>
Parameters
Type | Name | Description |
---|---|---|
void* | data | Data to sort. |
int | left | Left boundary. |
int | right | Right boundary. |
Type Parameters
Name | Description |
---|---|
TValue | Value type. |
TKey | Key Type. |
TGetter | Getter type. |
RadixSort(uint[], int, ref uint[], int)
Radix sort or bucket sort, stable and non in place.
Declaration
public static void RadixSort(uint[] arr, int sortSize, ref uint[] supportArray, int radixBits = 8)
Parameters
Type | Name | Description |
---|---|---|
uint[] | arr | Array to sort. |
int | sortSize | Size of the array to sort. If greater than array capacity, it will get clamped. |
uint[] | supportArray | Array of uints that is used for support data. The algorithm will automatically allocate it if necessary. |
int | radixBits | Number of bits to use for each bucket. Can only be 8, 4 or 2. |
RadixSort(NativeArray<uint>, int, ref NativeArray<uint>, int)
Radix sort or bucket sort, stable and non in place.
Declaration
public static void RadixSort(NativeArray<uint> array, int sortSize, ref NativeArray<uint> supportArray, int radixBits = 8)
Parameters
Type | Name | Description |
---|---|---|
NativeArray<uint> | array | Array to sort. |
int | sortSize | Size of the array to sort. If greater than array capacity, it will get clamped. |
NativeArray<uint> | supportArray | Array of uints that is used for support data. The algorithm will automatically allocate it if necessary. |
int | radixBits | Number of bits to use for each bucket. Can only be 8, 4 or 2. |