docs.unity.cn
    Show / Hide Table of Contents

    Class NativeSortExtension

    Extension methods for sorting collections.

    Inheritance
    Object
    NativeSortExtension
    Namespace: Unity.Collections
    Syntax
    public static class NativeSortExtension : object

    Methods

    BinarySearch<T>(T*, Int32, T)

    Finds a value in a sorted array by binary search.

    Declaration
    public static int BinarySearch<T>(T*ptr, int length, T value)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    T* ptr

    The array to search.

    Int32 length

    The number of elements to search. Indexes greater than or equal to length won't be searched.

    T value

    The value to locate.

    Returns
    Type Description
    Int32

    If found, the index of the located value. If not found, the return value is negative.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Remarks

    If the array is not sorted, the value might not be found, even if it's present in the array.

    BinarySearch<T>(NativeArray<T>, T)

    Finds a value in this sorted array by binary search.

    Declaration
    public static int BinarySearch<T>(this NativeArray<T> array, T value)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    NativeArray<T> array

    The array to search.

    T value

    The value to locate.

    Returns
    Type Description
    Int32

    If found, the index of the located value. If not found, the return value is negative.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Remarks

    If the array is not sorted, the value might not be found, even if it's present in this array.

    BinarySearch<T>(NativeSlice<T>, T)

    Finds a value in this sorted slice by binary search.

    Declaration
    public static int BinarySearch<T>(this NativeSlice<T> slice, T value)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    NativeSlice<T> slice

    The slice to search.

    T value

    The value to locate.

    Returns
    Type Description
    Int32

    If found, the index of the located value. If not found, the return value is negative.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Remarks

    If this slice is not sorted, the value might not be found, even if it's present in this slice.

    BinarySearch<T>(UnsafeList<T>, T)

    Finds a value in this sorted list by binary search.

    Declaration
    public static int BinarySearch<T>(this UnsafeList<T> list, T value)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    UnsafeList<T> list

    The list to search.

    T value

    The value to locate.

    Returns
    Type Description
    Int32

    If found, the index of the located value. If not found, the return value is negative.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Remarks

    If this list is not sorted, the value might not be found, even if it's present in this list.

    BinarySearch<T>(NativeList<T>, T)

    Finds a value in this sorted list by binary search.

    Declaration
    public static int BinarySearch<T>(this NativeList<T> list, T value)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    NativeList<T> list

    The list to search.

    T value

    The value to locate.

    Returns
    Type Description
    Int32

    If found, the index of the located value. If not found, the return value is negative.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Remarks

    If this list is not sorted, the value might not be found, even if it's present in this list.

    BinarySearch<T, U>(T*, Int32, T, U)

    Finds a value in a sorted array by binary search using a custom comparison.

    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

    The array to search.

    Int32 length

    The number of elements to search. Indexes greater than or equal to length won't be searched.

    T value

    The value to locate.

    U comp

    The comparison function used to determine the relative order of the elements.

    Returns
    Type Description
    Int32

    If found, the index of the located value. If not found, the return value is negative.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Remarks

    If the array is not sorted, the value might not be found, even if it's present in the array.

    BinarySearch<T, U>(NativeArray<T>, T, U)

    Finds a value in this sorted array by binary search using a custom comparison.

    Declaration
    public static int BinarySearch<T, U>(this NativeArray<T> array, T value, U comp)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    NativeArray<T> array

    The array to search.

    T value

    The value to locate.

    U comp

    The comparison function used to determine the relative order of the elements.

    Returns
    Type Description
    Int32

    If found, the index of the located value. If not found, the return value is negative.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The comparer type.

    Remarks

    If the array is not sorted, the value might not be found, even if it's present in this array.

    BinarySearch<T, U>(NativeSlice<T>, T, U)

    Finds a value in this sorted slice by binary search using a custom comparison.

    Declaration
    public static int BinarySearch<T, U>(this NativeSlice<T> slice, T value, U comp)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    NativeSlice<T> slice

    The slice to search.

    T value

    The value to locate.

    U comp

    The comparison function used to determine the relative order of the elements.

    Returns
    Type Description
    Int32

    If found, the index of the located value. If not found, the return value is negative.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Remarks

    If this slice is not sorted, the value might not be found, even if it's present in this slice.

    BinarySearch<T, U>(UnsafeList<T>, T, U)

    Finds a value in this sorted list by binary search using a custom comparison.

    Declaration
    public static int BinarySearch<T, U>(this UnsafeList<T> list, T value, U comp)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    UnsafeList<T> list

    The list to search.

    T value

    The value to locate.

    U comp

    The comparison function used to determine the relative order of the elements.

    Returns
    Type Description
    Int32

    If found, the index of the located value. If not found, the return value is negative.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Remarks

    If this list is not sorted, the value might not be found, even if it's present in this list.

    BinarySearch<T, U>(NativeList<T>, T, U)

    Finds a value in this sorted list by binary search using a custom comparison.

    Declaration
    public static int BinarySearch<T, U>(this NativeList<T> list, T value, U comp)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    NativeList<T> list

    The list to search.

    T value

    The value to locate.

    U comp

    The comparison function used to determine the relative order of the elements.

    Returns
    Type Description
    Int32

    If found, the index of the located value. If not found, the return value is negative.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Remarks

    If this list is not sorted, the value may not be found, even if it's present in this list.

    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

    The array to sort.

    Int32 length

    The number of elements to sort in the array. Indexes greater than or equal to length won't be included in the sort.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Sort<T>(T*, Int32, JobHandle)

    Creates and schedules a job that will sort 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

    The array to sort.

    Int32 length

    The number of elements to sort in the array. Indexes greater than or equal to length won't be included in the sort.

    JobHandle inputDeps

    A job handle which the newly created job will depend upon.

    Returns
    Type Description
    JobHandle

    The handle of the new job which will sort the array.

    Type Parameters
    Name Description
    T

    The type of elements.

    Sort<T>(NativeArray<T>)

    Sorts this 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

    The array to sort.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Sort<T>(NativeArray<T>, JobHandle)

    Sorts this 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

    The array to 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 this 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

    The slice to sort.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Sort<T>(NativeSlice<T>, JobHandle)

    Sorts this slice in ascending order.

    Declaration
    public static JobHandle Sort<T>(this NativeSlice<T> slice, JobHandle inputDeps)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    NativeSlice<T> slice

    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 this 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

    The list to sort.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Sort<T>(UnsafeList<T>, JobHandle)

    Sorts this list in ascending order.

    Declaration
    public static JobHandle Sort<T>(this UnsafeList<T> list, JobHandle inputDeps)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    UnsafeList<T> list

    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>(NativeList<T>)

    Sorts this 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

    The list to sort.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Sort<T>(NativeList<T>, JobHandle)

    Sorts this list in ascending order.

    Declaration
    public static JobHandle Sort<T>(this NativeList<T> array, JobHandle inputDeps)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    NativeList<T> array

    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.

    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

    The array to sort.

    Int32 length

    The number of elements to sort in the array. Indexes greater than or equal to length won't be included in the sort.

    U comp

    The comparison function used to determine the relative order of the elements.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    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 determines 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 this array using a custom comparison.

    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

    The array to sort.

    U comp

    The comparison function used to determine the relative order of the elements.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Sort<T, U>(NativeArray<T>, U, JobHandle)

    Sorts this 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

    The array to sort.

    U comp

    A comparison function that determines 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 this slice using a custom comparison.

    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

    The slice to sort.

    U comp

    The comparison function used to determine the relative order of the elements.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Sort<T, U>(NativeSlice<T>, U, JobHandle)

    Sorts this slice using a custom comparison function.

    Declaration
    public static JobHandle Sort<T, U>(this NativeSlice<T> slice, U comp, JobHandle inputDeps)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    NativeSlice<T> slice

    The container to perform sort.

    U comp

    A comparison function that determines 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 the list using a custom comparison.

    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

    The list to sort.

    U comp

    The comparison function used to determine the relative order of the elements.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Sort<T, U>(UnsafeList<T>, U, JobHandle)

    Sorts this list using a custom comparison function.

    Declaration
    public static JobHandle Sort<T, U>(this UnsafeList<T> list, U comp, JobHandle inputDeps)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    UnsafeList<T> list

    The container to perform sort.

    U comp

    A comparison function that determines 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 this list using a custom comparison.

    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

    The list to sort.

    U comp

    The comparison function used to determine the relative order of the elements.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Sort<T, U>(NativeList<T>, U, JobHandle)

    Sorts this list using a custom comparison function.

    Declaration
    public static JobHandle Sort<T, U>(this NativeList<T> list, U comp, JobHandle inputDeps)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    NativeList<T> list

    The container to perform sort.

    U comp

    A comparison function that determines 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.

    SortJob<T>(T*, Int32)

    Returns a job which will sort an array in ascending order.

    Declaration
    public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(T*array, int length)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    T* array

    The array to sort.

    Int32 length

    The number of elements to sort in the array. Indexes greater than or equal to length won't be included in the sort.

    Returns
    Type Description
    SortJob<T, NativeSortExtension.DefaultComparer<T>>

    A job for sorting the array.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Remarks

    This method does not schedule the job. Scheduling the job is left to you.

    SortJob<T>(NativeArray<T>)

    Returns a job which will sort this array in ascending order.

    Declaration
    public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(this NativeArray<T> array)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    NativeArray<T> array

    The array to sort.

    Returns
    Type Description
    SortJob<T, NativeSortExtension.DefaultComparer<T>>

    A job for sorting this array.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Remarks

    This method does not schedule the job. Scheduling the job is left to you.

    SortJob<T>(NativeSlice<T>)

    Returns a job which will sort this slice in ascending order.

    Declaration
    public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(this NativeSlice<T> slice)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    NativeSlice<T> slice

    The slice to sort.

    Returns
    Type Description
    SortJob<T, NativeSortExtension.DefaultComparer<T>>

    A job for sorting this slice.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Remarks

    This method does not schedule the job. Scheduling the job is left to you.

    SortJob<T>(UnsafeList<T>)

    Returns a job which will sort this list in ascending order.

    Declaration
    public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(this UnsafeList<T> list)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    UnsafeList<T> list

    The list to sort.

    Returns
    Type Description
    SortJob<T, NativeSortExtension.DefaultComparer<T>>

    A job for sorting this list.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Remarks

    This method does not schedule the job. Scheduling the job is left to you.

    SortJob<T>(NativeList<T>)

    Returns a job which will sort this list in ascending order.

    Declaration
    public static SortJob<T, NativeSortExtension.DefaultComparer<T>> SortJob<T>(this NativeList<T> list)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    NativeList<T> list

    The list to sort.

    Returns
    Type Description
    SortJob<T, NativeSortExtension.DefaultComparer<T>>

    A job for sorting this list.

    Type Parameters
    Name Description
    T

    The type of the elements.

    Remarks

    This method does not schedule the job. Scheduling the job is left to you.

    SortJob<T, U>(T*, Int32, U)

    Returns a job which will sort an array using a custom comparison.

    Declaration
    public static SortJob<T, U> SortJob<T, U>(T*array, int length, U comp)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    T* array

    The array to sort.

    Int32 length

    The number of elements to sort in the array. Indexes greater than or equal to length won't be included in the sort.

    U comp

    The comparison function used to determine the relative order of the elements.

    Returns
    Type Description
    SortJob<T, U>

    A job for sorting the array.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Remarks

    This method does not schedule the job. Scheduling the job is left to you.

    SortJob<T, U>(NativeArray<T>, U)

    Returns a job which will sort this array using a custom comparison.

    Declaration
    public static SortJob<T, U> SortJob<T, U>(this NativeArray<T> array, U comp)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    NativeArray<T> array

    The array to sort.

    U comp

    The comparison function used to determine the relative order of the elements.

    Returns
    Type Description
    SortJob<T, U>

    A job for sorting the array.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Remarks

    This method does not schedule the job. Scheduling the job is left to you.

    SortJob<T, U>(NativeSlice<T>, U)

    Returns a job which will sort this slice using a custom comparison.

    Declaration
    public static SortJob<T, U> SortJob<T, U>(this NativeSlice<T> slice, U comp)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    NativeSlice<T> slice

    The slice to sort.

    U comp

    The comparison function used to determine the relative order of the elements.

    Returns
    Type Description
    SortJob<T, U>

    A job for sorting this slice.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Remarks

    This method does not schedule the job. Scheduling the job is left to you.

    SortJob<T, U>(UnsafeList<T>, U)

    Returns a job which will sort this list using a custom comparison.

    Declaration
    public static SortJob<T, U> SortJob<T, U>(this UnsafeList<T> list, U comp)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    UnsafeList<T> list

    The list to sort.

    U comp

    The comparison function used to determine the relative order of the elements.

    Returns
    Type Description
    SortJob<T, U>

    A job for sorting this list.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Remarks

    This method does not schedule the job. Scheduling the job is left to you.

    SortJob<T, U>(NativeList<T>, U)

    Returns a job which will sort this list using a custom comparison.

    Declaration
    public static SortJob<T, U> SortJob<T, U>(this NativeList<T> list, U comp)
        where T : struct where U : IComparer<T>
    Parameters
    Type Name Description
    NativeList<T> list

    The list to sort.

    U comp

    The comparison function used to determine the relative order of the elements.

    Returns
    Type Description
    SortJob<T, U>

    A job for sorting this list.

    Type Parameters
    Name Description
    T

    The type of the elements.

    U

    The type of the comparer.

    Remarks

    This method does not schedule the job. Scheduling the job is left to you.

    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on Wednesday, September 29, 2021