Class NativeArrayExtensions
Extension methods for NativeArray.
Namespace: Unity.Collections
Assembly: Unity.Collections.dll
Syntax
public static class NativeArrayExtensions
Methods
ArraysEqual<T>(NativeArray<T>, NativeArray<T>)
Returns true if this array and another have equal length and content.
Declaration
public static bool ArraysEqual<T>(this NativeArray<T> container, NativeArray<T> other) where T : unmanaged, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | container | The array to compare for equality. |
NativeArray<T> | other | The other array to compare for equality. |
Returns
Type | Description |
---|---|
bool | True if the arrays have equal length and content. |
Type Parameters
Name | Description |
---|---|
T | The type of the source array's elements. |
Contains<T, U>(void*, int, U)
Returns true if a particular value is present in a buffer.
Declaration
public static bool Contains<T, U>(void* ptr, int length, U value) where T : unmanaged, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
void* | ptr | The buffer. |
int | length | Number of elements in the buffer. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
bool | True if the value is present in the buffer. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the buffer. |
U | The value type. |
Contains<T, U>(NativeArray<T>, U)
Returns true if a particular value is present in this array.
Declaration
public static bool Contains<T, U>(this NativeArray<T> array, U value) where T : unmanaged, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | The array to search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
bool | True if the value is present in this array. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in this array. |
U | The value type. |
Contains<T, U>(ReadOnly, U)
Returns true if a particular value is present in this array.
Declaration
public static bool Contains<T, U>(this NativeArray<T>.ReadOnly array, U value) where T : unmanaged, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T>.ReadOnly | array | The array to search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
bool | True if the value is present in this array. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in this array. |
U | The value type. |
CopyFrom<T>(ref NativeArray<T>, in UnsafeHashSet<T>)
Copies all elements of specified container to array.
Declaration
public static void CopyFrom<T>(this ref NativeArray<T> container, in UnsafeHashSet<T> other) where T : unmanaged, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | container | Container to copy to. |
UnsafeHashSet<T> | other | An container to copy into this array. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in this container. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the array and container have unequal length. |
CopyFrom<T>(ref NativeArray<T>, in NativeHashSet<T>)
Copies all elements of specified container to array.
Declaration
public static void CopyFrom<T>(this ref NativeArray<T> container, in NativeHashSet<T> other) where T : unmanaged, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | container | Container to copy to. |
NativeHashSet<T> | other | An container to copy into this array. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in this container. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the array and container have unequal length. |
CopyFrom<T>(ref NativeArray<T>, NativeList<T>)
Copies all elements of specified container to array.
Declaration
public static void CopyFrom<T>(this ref NativeArray<T> container, NativeList<T> other) where T : unmanaged, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | container | Container to copy to. |
NativeList<T> | other | An container to copy into this array. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in this container. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the array and container have unequal length. |
IndexOf<T, U>(void*, int, U)
Finds the index of the first occurrence of a particular value in a buffer.
Declaration
public static int IndexOf<T, U>(void* ptr, int length, U value) where T : unmanaged, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
void* | ptr | A buffer. |
int | length | Number of elements in the buffer. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
int | The index of the first occurrence of the value in the buffer. Returns -1 if no occurrence is found. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the buffer. |
U | The value type. |
IndexOf<T, U>(NativeArray<T>, U)
Finds the index of the first occurrence of a particular value in this array.
Declaration
public static int IndexOf<T, U>(this NativeArray<T> array, U value) where T : unmanaged, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | The array to search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
int | The index of the first occurrence of the value in this array. Returns -1 if no occurrence is found. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in this array. |
U | The value type. |
IndexOf<T, U>(ReadOnly, U)
Finds the index of the first occurrence of a particular value in this array.
Declaration
public static int IndexOf<T, U>(this NativeArray<T>.ReadOnly array, U value) where T : unmanaged, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T>.ReadOnly | array | The array to search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
int | The index of the first occurrence of the value in this array. Returns -1 if no occurrence is found. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in this array. |
U | The type of value to locate. |
Reinterpret<T, U>(NativeArray<T>)
Returns the reinterpretation of this array into another kind of NativeArray. See Array reinterpretation.
Declaration
public static NativeArray<U> Reinterpret<T, U>(this NativeArray<T> array) where T : unmanaged where U : unmanaged
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | The array to reinterpret. |
Returns
Type | Description |
---|---|
NativeArray<U> | The reinterpretation of this array into another kind of NativeArray. |
Type Parameters
Name | Description |
---|---|
T | Type of elements in the array. |
U | Type of elements in the reinterpreted array. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this array's capacity cannot be evenly divided by |