Class UnsafeListExtension
Provides extension methods for UnsafeList.
Namespace: Unity.Collections.LowLevel.Unsafe
Assembly: Unity.Collections.dll
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 : unmanaged, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
UnsafeList | container | The container to perform search. |
T | value | The value to search for. |
Returns
Type | Description |
---|---|
int | 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 : unmanaged where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
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 |
---|---|
int | 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.
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 : unmanaged, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
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 : unmanaged where U : IComparer<T>
Parameters
Type | Name | Description |
---|---|---|
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. |
Sort<T>(UnsafeList)
Sorts a list in ascending order.
Declaration
public static void Sort<T>(this UnsafeList list) where T : unmanaged, IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
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 : unmanaged 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. |