class MAGES::MeshDeformations::Utilities::NativeCollectionsExtensions

Overview

Extension methods for Unity’s NativeCollections. More…

class NativeCollectionsExtensions
{
public:
    // methods

    static float3 InterlockedAddFloat3(
        this NativeArray arr,
        NativeArray locks,
        int index,
        float3 val
    );

    static float InterlockedAddFloat(
        this NativeArray arr,
        NativeArray locks,
        int index,
        float val
    );

    static int InterlockedAdd(this NativeArray arr, int index, int val);
    static int InterlockedAdd(this NativeReference nativeRef, int val);

    static int InterlockedCompareExchange(
        this NativeArray arr,
        int index,
        int value,
        int comparand
    );

    static void ResizeArray< T >(
        this ref NativeArray array,
        int capacity,
        Allocator allocator = Allocator.Persistent,
        NativeArrayOptions options = NativeArrayOptions.UninitializedMemory
    );

    static void InsertSpace< T >(
        this ref NativeArray array,
        int additionalSize,
        int insertionIndex,
        Allocator allocator,
        NativeArrayOptions newSpaceOptions = NativeArrayOptions.ClearMemory
    );

    static void RemoveRange< T >(
        this ref NativeArray array,
        int index,
        int length,
        Allocator allocator
    );

    static void RemoveAt< T >(
        this ref NativeArray array,
        int index,
        Allocator allocator
    );
};

Detailed Documentation

Extension methods for Unity’s NativeCollections.

Methods

static float3 InterlockedAddFloat3(
    this NativeArray arr,
    NativeArray locks,
    int index,
    float3 val
)

Atomic add for float3 in a NativeArray.

Parameters:

arr

The array.

locks

The locks array.

index

The index of the position to add to.

val

The value to add to that position.

Returns:

The new value that was stored at index by this operation.

static float InterlockedAddFloat(
    this NativeArray arr,
    NativeArray locks,
    int index,
    float val
)

Atomic add for float in a NativeArray.

Parameters:

arr

The array.

locks

The locks array.

index

The index in which to add to.

val

The value to add.

Returns:

The new value that was stored at index by this operation.

static int InterlockedAdd(this NativeArray arr, int index, int val)

Atomically adds a value to an integer in a NativeArray.

Parameters:

arr

The array.

index

The index of the array in which to add to.

val

The value to add.

Returns:

The new value that was stored at index by this operation.

static int InterlockedAdd(this NativeReference nativeRef, int val)

Atomically adds a value to an integer in a NativeReference.

Parameters:

nativeRef

The native ref.

val

The value to add.

Returns:

The new value that was stored at nativeRef by this operation.

static int InterlockedCompareExchange(
    this NativeArray arr,
    int index,
    int value,
    int comparand
)

Compares two values for equality and, if they are equal, replaces the first value.

Parameters:

arr

The array.

index

The index of the value whose value is compared with the value of comparand and possibly replaced by value.

value

The value that replaces the destination value if the comparison results in equality.

comparand

The value that is compared to the value of the array at index.

Returns:

The original value of the array at index.

static void ResizeArray< T >(
    this ref NativeArray array,
    int capacity,
    Allocator allocator = Allocator.Persistent,
    NativeArrayOptions options = NativeArrayOptions.UninitializedMemory
)

Resizes the array.

Parameters:

T

The type of the NativeArray.

array

The array to resize.

capacity

The new size of the array.

allocator

The memory allocator.

options

The memory options.

static void InsertSpace< T >(
    this ref NativeArray array,
    int additionalSize,
    int insertionIndex,
    Allocator allocator,
    NativeArrayOptions newSpaceOptions = NativeArrayOptions.ClearMemory
)

Inserts space into the array.

Parameters:

T

The type of the elements in the array.

array

The array to modify.

additionalSize

The size of the space to insert.

insertionIndex

The index at which the empty space will begin.

allocator

The memory allocator.

newSpaceOptions

The memory options for the new space.

static void RemoveRange< T >(
    this ref NativeArray array,
    int index,
    int length,
    Allocator allocator
)

Removes a range of elements from the array.

Parameters:

T

The type of the elements in the array.

array

The array to modify.

index

The index of the first element to remove.

length

The length of the range.

allocator

The memory allocator.

static void RemoveAt< T >(
    this ref NativeArray array,
    int index,
    Allocator allocator
)

Remove item at position.

Parameters:

T

The type of the elements in the array.

array

The array to modify.

index

The index of the element to remove.

allocator

The memory allocator.