docs.unity3d.com
    Show / Hide Table of Contents

    Class CoreUnsafeUtils

    Static class with unsafe utility functions.

    Inheritance
    Object
    CoreUnsafeUtils
    Namespace: UnityEngine.Rendering
    Syntax
    public static class CoreUnsafeUtils

    Methods

    CombineHashes(Int32, Hash128*, Hash128*)

    Combine hashes.

    Declaration
    public static void CombineHashes(int count, Hash128*hashes, Hash128*outHash)
    Parameters
    Type Name Description
    Int32 count

    Number of hash to combine.

    Hash128* hashes

    Hashes to combine.

    Hash128* outHash

    Hash to update.

    CombineHashes<TValue, TGetter>(Int32, 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
    Int32 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(Int32, Hash128*, Int32, Hash128*, Int32*, Int32*, out Int32, out Int32)

    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
    Int32 oldHashCount

    Number of hashes in oldHashes.

    Hash128* oldHashes

    Previous hashes to compare.

    Int32 newHashCount

    Number of hashes in newHashes.

    Hash128* newHashes

    New hashes to compare.

    Int32* addIndices

    Indices of element to add in newHashes will be written here.

    Int32* removeIndices

    Indices of element to remove in oldHashes will be written here.

    Int32 addCount

    Number of elements to add will be written here.

    Int32 remCount

    Number of elements to remove will be written here.

    Returns
    Type Description
    Int32

    The number of operation to perform (

    addCount + remCount
    )

    CompareHashes<TOldValue, TOldGetter, TNewValue, TNewGetter>(Int32, Void*, Int32, Void*, Int32*, Int32*, out Int32, out Int32)

    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
    Int32 oldHashCount

    Number of hashes in oldHashes.

    Void* oldHashes

    Previous hashes to compare.

    Int32 newHashCount

    Number of hashes in newHashes.

    Void* newHashes

    New hashes to compare.

    Int32* addIndices

    Indices of element to add in newHashes will be written here.

    Int32* removeIndices

    Indices of element to remove in oldHashes will be written here.

    Int32 addCount

    Number of elements to add will be written here.

    Int32 remCount

    Number of elements to remove will be written here.

    Returns
    Type Description
    Int32

    The number of operation to perform (

    addCount + remCount
    )

    Type Parameters
    Name Description
    TOldValue

    Old value type.

    TOldGetter

    Old getter type.

    TNewValue

    New value type.

    TNewGetter

    New getter type.

    CopyTo<T>(T[], Void*, Int32)

    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.

    Int32 count

    Number of elements to copy.

    Type Parameters
    Name Description
    T

    Type of the provided array.

    CopyTo<T>(List<T>, Void*, Int32)

    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.

    Int32 count

    Number of elements to copy.

    Type Parameters
    Name Description
    T

    Type of the provided List.

    HaveDuplicates(Int32[])

    Checks for duplicates in an array.

    Declaration
    public static bool HaveDuplicates(int[] arr)
    Parameters
    Type Name Description
    Int32[] arr

    Input array.

    Returns
    Type Description
    Boolean

    True if there is any duplicate in the input array.

    IndexOf<T>(Void*, Int32, 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.

    Int32 count

    Number of elements.

    T v

    Element to test against.

    Returns
    Type Description
    Int32

    The first index of the provided element.

    Type Parameters
    Name Description
    T

    Data type.

    QuickSort(UInt32[], Int32, Int32)

    Quick Sort

    Declaration
    public static void QuickSort(uint[] arr, int left, int right)
    Parameters
    Type Name Description
    UInt32[] arr

    uint array.

    Int32 left

    Left boundary.

    Int32 right

    Left boundary.

    QuickSort<T>(Int32, Void*)

    Quick sort.

    Declaration
    public static void QuickSort<T>(int count, void *data)
        where T : struct, IComparable<T>
    Parameters
    Type Name Description
    Int32 count

    Number of element.

    Void* data

    Buffer to sort.

    Type Parameters
    Name Description
    T

    Type to compare.

    QuickSort<TValue, TKey, TGetter>(Int32, 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
    Int32 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*, Int32, Int32)

    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.

    Int32 left

    Left boundary.

    Int32 right

    Right boundary.

    Type Parameters
    Name Description
    TValue

    Value type.

    TKey

    Key Type.

    TGetter

    Getter type.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023