Class NativeArrayExtensions
Extension methods for NativeArray.
Namespace: Unity.Collections
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> array, NativeArray<T> other)
where T : struct, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | The array to compare for equality. |
NativeArray<T> | other | The other array to compare for equality. |
Returns
Type | Description |
---|---|
Boolean | True if the arrays have equal length and content. |
Type Parameters
Name | Description |
---|---|
T | The type of the source array's elements. |
ArraysEqual<T>(NativeList<T>, NativeArray<T>)
Returns true if this array and another have equal length and content.
Declaration
public static bool ArraysEqual<T>(this NativeList<T> array, NativeArray<T> other)
where T : struct, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
NativeList<T> | array | The array to compare for equality. |
NativeArray<T> | other | The other array to compare for equality. |
Returns
Type | Description |
---|---|
Boolean | 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*, Int32, 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 : struct, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
Void* | ptr | The buffer. |
Int32 | length | Number of elements in the buffer. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Boolean | 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 : struct, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | The array to search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Boolean | 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>(NativeArray<T>.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 : struct, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
NativeArray.ReadOnly<> | array | The array to search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Boolean | 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>(NativeList<T>, U)
Returns true if a particular value is present in this list.
Declaration
public static bool Contains<T, U>(this NativeList<T> list, U value)
where T : struct, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
NativeList<T> | list | The list to search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Boolean | True if the value is present in this list. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in this list. |
U | The value type. |
IndexOf<T, U>(Void*, Int32, 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 : struct, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
Void* | ptr | A buffer. |
Int32 | length | Number of elements in the buffer. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Int32 | 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 : struct, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
NativeArray<T> | array | The array to search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Int32 | 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>(NativeArray<T>.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 : struct, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
NativeArray.ReadOnly<> | array | The array to search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Int32 | 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. |
IndexOf<T, U>(NativeList<T>, U)
Finds the index of the first occurrence of a particular value in this list.
Declaration
public static int IndexOf<T, U>(this NativeList<T> list, U value)
where T : struct, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
NativeList<T> | list | The list to search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Int32 | The index of the first occurrence of the value in this list. Returns -1 if no occurrence is found. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the list. |
U | The value type. |
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 : struct where U : struct
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 |