Struct InplaceArray<T>
An array-like object that stores up to four elements. This is a value type that does not allocate any additional memory.
Implements
Inherited Members
Namespace: Unity.MLAgents
Assembly: Unity.ML-Agents.dll
Syntax
public struct InplaceArray<T> : IEquatable<InplaceArray<T>> where T : struct
Type Parameters
Name | Description |
---|---|
T | T |
Remarks
This does not implement any interfaces such as IList, in order to avoid any accidental boxing allocations.
Constructors
InplaceArray(T)
Create a length-1 array.
Declaration
public InplaceArray(T elem0)
Parameters
Type | Name | Description |
---|---|---|
T | elem0 | Length of axis 0. |
InplaceArray(T, T)
Create a length-2 array.
Declaration
public InplaceArray(T elem0, T elem1)
Parameters
Type | Name | Description |
---|---|---|
T | elem0 | Length of axis 0. |
T | elem1 | Length of axis 1. |
InplaceArray(T, T, T)
Create a length-3 array.
Declaration
public InplaceArray(T elem0, T elem1, T elem2)
Parameters
Type | Name | Description |
---|---|---|
T | elem0 | Length of axis 0. |
T | elem1 | Length of axis 1. |
T | elem2 | Length of axis 2. |
InplaceArray(T, T, T, T)
Create a length-3 array.
Declaration
public InplaceArray(T elem0, T elem1, T elem2, T elem3)
Parameters
Type | Name | Description |
---|---|---|
T | elem0 | Length of axis 0. |
T | elem1 | Length of axis 1. |
T | elem2 | Length of axis 2. |
T | elem3 | Length of axis 3. |
Properties
this[int]
Per-element access.
Declaration
public T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The index to get or set. |
Property Value
Type | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
Index |
Index out of range |
Length
The length of the array.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
int |
Methods
Equals(object)
Check that the arrays are equivalent.
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
object | other | The other 'InplaceArray' to compare. |
Returns
Type | Description |
---|---|
bool | Whether the arrays are not equivalent |
Overrides
Equals(InplaceArray<T>)
Check that the arrays are equivalent.
Declaration
public bool Equals(InplaceArray<T> other)
Parameters
Type | Name | Description |
---|---|---|
Inplace |
other | The other 'InplaceArray' to compare. |
Returns
Type | Description |
---|---|
bool | Whether the arrays are not equivalent |
FromList(IList<T>)
Construct an InplaceArray from an IList (e.g. Array or List). The source must be non-empty and have at most 4 elements.
Declaration
public static InplaceArray<T> FromList(IList<T> elems)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | elems | The |
Returns
Type | Description |
---|---|
Inplace |
Corresponding |
Exceptions
Type | Condition |
---|---|
Argument |
Argument out of range |
GetHashCode()
Get a hashcode for the array.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | The hashcode of the |
Overrides
ToString()
Returns a string representation of the array's elements.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The string summary of the |
Overrides
Exceptions
Type | Condition |
---|---|
Index |
Index out of range |
Operators
operator ==(InplaceArray<T>, InplaceArray<T>)
Check that the arrays have the same length and have all equal values.
Declaration
public static bool operator ==(InplaceArray<T> lhs, InplaceArray<T> rhs)
Parameters
Type | Name | Description |
---|---|---|
Inplace |
lhs | The first 'InplaceArray' to compare. |
Inplace |
rhs | The second 'InplaceArray' to compare. |
Returns
Type | Description |
---|---|
bool | Whether the arrays are equivalent. |
operator !=(InplaceArray<T>, InplaceArray<T>)
Check that the arrays are not equivalent.
Declaration
public static bool operator !=(InplaceArray<T> lhs, InplaceArray<T> rhs)
Parameters
Type | Name | Description |
---|---|---|
Inplace |
lhs | The first 'InplaceArray' to compare. |
Inplace |
rhs | The second 'InplaceArray' to compare. |
Returns
Type | Description |
---|---|
bool | Whether the arrays are not equivalent |