Class NativeSortExtension
Extension methods for sorting various containers.
Namespace: Unity.Collections
Syntax
public static class NativeSortExtension
Methods
BinarySearch<T>(T*, Int32, T)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T>(T*ptr, int length, T value)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
T* | ptr | Array to perform sort. |
Int32 | length | Number of elements to perform binary search. |
T | value | The value to search in sorted array. |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T>(UnsafeList, T)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T>(this UnsafeList container, T value)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList | container | The container to perform search. |
T | value | The value to search for. |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T>(UnsafeList<T>, T)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T>(this UnsafeList<T> container, T value)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList<T> | container | The container to perform search. |
T | value | The value to search for. |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T>(NativeArray<T>, T)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T>(this NativeArray<T> container, T value)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | container | The container to perform search. |
T | value | The value to search for. |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T>(NativeList<T>, T)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T>(this NativeList<T> container, T value)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeList<T> | container | The container to perform search. |
T | value | The value to search for. |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T>(NativeSlice<T>, T)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T>(this NativeSlice<T> container, T value)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeSlice<T> | container | The container to perform search. |
T | value | The value to search for. |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T, U>(T*, Int32, T, U)
Binary search for the value in the sorted array.
Declaration
public static int BinarySearch<T, U>(T*ptr, int length, T value, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
T* | ptr | Array to perform binary search. |
Int32 | length | Number of elements to perform binary search. |
T | value | The value to search in sorted array. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T, U>(UnsafeList, T, U)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T, U>(this UnsafeList container, T value, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList | container | The container to perform search. |
T | value | The value to search for. |
U | comp |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T, U>(UnsafeList<T>, T, U)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T, U>(this UnsafeList<T> container, T value, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList<T> | container | The container to perform search. |
T | value | The value to search for. |
U | comp |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T, U>(NativeArray<T>, T, U)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T, U>(this NativeArray<T> container, T value, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | container | The container to perform search. |
T | value | The value to search for. |
U | comp |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T, U>(NativeList<T>, T, U)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T, U>(this NativeList<T> container, T value, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
NativeList<T> | container | The container to perform search. |
T | value | The value to search for. |
U | comp |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
BinarySearch<T, U>(NativeSlice<T>, T, U)
Binary search for the value in the sorted container.
Declaration
public static int BinarySearch<T, U>(this NativeSlice<T> container, T value, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
NativeSlice<T> | container | The container to perform search. |
T | value | The value to search for. |
U | comp |
Returns
Type | Description |
---|---|
Int32 | Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Remarks
Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.
Sort<T>(T*, Int32)
Sorts an array in ascending order.
Declaration
public static void Sort<T>(T*array, int length)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
T* | array | Array to perform sort. |
Int32 | length | Number of elements to perform sort. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(T*, Int32, JobHandle)
Sorts an array in ascending order.
Declaration
public static JobHandle Sort<T>(T*array, int length, JobHandle inputDeps)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
T* | array | Array to perform sort. |
Int32 | length | Number of elements to perform sort. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(UnsafeList)
Sorts a list in ascending order.
Declaration
public static void Sort<T>(this UnsafeList list)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList | list | List to perform sort. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(UnsafeList, JobHandle)
Sorts the container in ascending order.
Declaration
public static JobHandle Sort<T>(this UnsafeList container, JobHandle inputDeps)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList | container | The container to perform sort. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(UnsafeList<T>)
Sorts a list in ascending order.
Declaration
public static void Sort<T>(this UnsafeList<T> list)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList<T> | list | List to perform sort. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(UnsafeList<T>, JobHandle)
Sorts the container in ascending order.
Declaration
public static JobHandle Sort<T>(this UnsafeList<T> container, JobHandle inputDeps)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList<T> | container | The container to perform sort. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(NativeArray<T>)
Sorts an array in ascending order.
Declaration
public static void Sort<T>(this NativeArray<T> array)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | Array to perform sort. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(NativeArray<T>, JobHandle)
Sorts an array in ascending order.
Declaration
public static JobHandle Sort<T>(this NativeArray<T> array, JobHandle inputDeps)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | Array to perform sort. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(NativeList<T>)
Sorts a list in ascending order.
Declaration
public static void Sort<T>(this NativeList<T> list)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeList<T> | list | List to perform sort. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(NativeList<T>, JobHandle)
Sorts the container in ascending order.
Declaration
public static JobHandle Sort<T>(this NativeList<T> container, JobHandle inputDeps)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeList<T> | container | The container to perform sort. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(NativeSlice<T>)
Sorts a slice in ascending order.
Declaration
public static void Sort<T>(this NativeSlice<T> slice)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeSlice<T> | slice | Slice to perform sort. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T>(NativeSlice<T>, JobHandle)
Sorts the container in ascending order.
Declaration
public static JobHandle Sort<T>(this NativeSlice<T> container, JobHandle inputDeps)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeSlice<T> | container | The container to perform sort. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
Sort<T, U>(T*, Int32, U)
Sorts an array using a custom comparison function.
Declaration
public static void Sort<T, U>(T*array, int length, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
T* | array | Array to perform sort. |
Int32 | length | Number of elements to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(T*, Int32, U, JobHandle)
Sorts an array using a custom comparison function.
Declaration
public static JobHandle Sort<T, U>(T*array, int length, U comp, JobHandle inputDeps)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
T* | array | Array to perform sort. |
Int32 | length | Number of elements to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(UnsafeList, U)
Sorts a list using a custom comparison function.
Declaration
public static void Sort<T, U>(this UnsafeList list, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList | list | List to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(UnsafeList, U, JobHandle)
Sorts the container using a custom comparison function.
Declaration
public static JobHandle Sort<T, U>(this UnsafeList container, U comp, JobHandle inputDeps)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList | container | The container to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(UnsafeList<T>, U)
Sorts a list using a custom comparison function.
Declaration
public static void Sort<T, U>(this UnsafeList<T> list, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList<T> | list | List to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(UnsafeList<T>, U, JobHandle)
Sorts the container using a custom comparison function.
Declaration
public static JobHandle Sort<T, U>(this UnsafeList<T> container, U comp, JobHandle inputDeps)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList<T> | container | The container to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(NativeArray<T>, U)
Sorts an array using a custom comparison function.
Declaration
public static void Sort<T, U>(this NativeArray<T> array, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | Array to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(NativeArray<T>, U, JobHandle)
Sorts an array using a custom comparison function.
Declaration
public static JobHandle Sort<T, U>(this NativeArray<T> array, U comp, JobHandle inputDeps)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(NativeList<T>, U)
Sorts a list using a custom comparison function.
Declaration
public static void Sort<T, U>(this NativeList<T> list, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
NativeList<T> | list | List to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(NativeList<T>, U, JobHandle)
Sorts the container using a custom comparison function.
Declaration
public static JobHandle Sort<T, U>(this NativeList<T> container, U comp, JobHandle inputDeps)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
NativeList<T> | container | The container to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(NativeSlice<T>, U)
Sorts a slice using a custom comparison function.
Declaration
public static void Sort<T, U>(this NativeSlice<T> slice, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
NativeSlice<T> | slice | List to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |
Sort<T, U>(NativeSlice<T>, U, JobHandle)
Sorts the container using a custom comparison function.
Declaration
public static JobHandle Sort<T, U>(this NativeSlice<T> container, U comp, JobHandle inputDeps)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
NativeSlice<T> | container | The container to perform sort. |
U | comp | A comparison function that indicates whether one element in the array is less than, equal to, or greater than another element. |
JobHandle | inputDeps | The job handle or handles for any scheduled jobs that use this container. |
Returns
Type | Description |
---|---|
JobHandle | A new job handle containing the prior handles as well as the handle for the job that sorts the container. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |