Class UnsafeListExtension
Provides extension methods for UnsafeList.
Namespace: Unity.Collections.LowLevel.Unsafe
Syntax
public static class UnsafeListExtension
Methods
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 |
---|---|---|
Unity.Collections.LowLevel.Unsafe.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, 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 |
---|---|---|
Unity.Collections.LowLevel.Unsafe.UnsafeList | container | The container to perform search. |
T | value | The value to search for. |
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.
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 |
---|---|---|
Unity.Collections.LowLevel.Unsafe.UnsafeList | list | List to perform sort. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
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 |
---|---|---|
Unity.Collections.LowLevel.Unsafe.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. |
SortJob<T>(UnsafeList)
Creates a job that will sort a list in ascending order.
Declaration
public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(this UnsafeList list)
where T : struct, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
Unity.Collections.LowLevel.Unsafe.UnsafeList | list | List to sort. |
Returns
Type | Description |
---|---|
SortJob<T, NativeSortExtension.DefaultComparer<T>> | The job that will sort the list. Scheduling the job is left to the user. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
SortJob<T, U>(UnsafeList, U)
Creates a job that will sort a list using a comparison function.
Declaration
public static SortJob<T, U> SortJob<T, U>(this UnsafeList list, U comp)
where T : struct where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
Unity.Collections.LowLevel.Unsafe.UnsafeList | list | List to sort. |
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 |
---|---|
SortJob<T, U> | The job that will sort the list. Scheduling the job is left to the user. |
Type Parameters
Name | Description |
---|---|
T | Source type of elements |
U | The comparer type. |