Class NativeArrayExtensions
Namespace: Unity.Collections
Syntax
public static class NativeArrayExtensions
Methods
ArraysEqual<T>(NativeArray<T>, NativeArray<T>)
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 | |
NativeArray<T> | other |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T |
Contains<T, U>(NativeArray<T>, U)
Determines whether an element is in the native 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 | Array to perform search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Boolean | True, if element is found. |
Type Parameters
Name | Description |
---|---|
T | The type of values in the array. |
U | The value type. |
Contains<T, U>(Void*, Int32, U)
Determines whether an element is in the array.
Declaration
public static bool Contains<T, U>(void *ptr, int length, U value)
where T : struct, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
Void* | ptr | Pointer to first element to perform search. |
Int32 | length | Number of elements to perform search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Boolean | True, if element is found. |
Type Parameters
Name | Description |
---|---|
T | The type of values in the array. |
U | The value type. |
Contains<T, U>(NativeList<T>, U)
Determines whether an element is in the native 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 | List to perform search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Boolean | True, if element is found. |
Type Parameters
Name | Description |
---|---|
T | The type of values in the list. |
U | The value type. |
IndexOf<T, U>(NativeArray<T>, U)
Searches for the specified element in native 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 | Array to perform search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Int32 | The zero-based index of the first occurrence element if found, otherwise returns -1. |
Type Parameters
Name | Description |
---|---|
T | The type of values in the array. |
U | The value type. |
IndexOf<T, U>(Void*, Int32, U)
Searches for the specified element in array.
Declaration
public static int IndexOf<T, U>(void *ptr, int length, U value)
where T : struct, IEquatable<U>
Parameters
Type | Name | Description |
---|---|---|
Void* | ptr | Pointer to first element to perform search. |
Int32 | length | Number of elements to perform search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Int32 | The zero-based index of the first occurrence element if found, otherwise returns -1. |
Type Parameters
Name | Description |
---|---|
T | The type of values in the array. |
U | The value type. |
IndexOf<T, U>(NativeList<T>, U)
Searches for the specified element in native 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 | List to perform search. |
U | value | The value to locate. |
Returns
Type | Description |
---|---|
Int32 | The zero-based index of the first occurrence element if found, otherwise returns -1. |
Type Parameters
Name | Description |
---|---|
T | The type of values in the list. |
U | The value type. |
Reinterpret<T, U>(NativeArray<T>)
Reinterpret a native array as being of another type, aliasing its contents via type punning.
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 alias |
Returns
Type | Description |
---|---|
NativeArray<U> | The same array, with a different type of element |
Type Parameters
Name | Description |
---|---|
T | Source type of array elements |
U | Target type of array elements |