docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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
    IEquatable<InplaceArray<T>>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    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
    IndexOutOfRangeException

    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
    ValueType.Equals(object)

    Equals(InplaceArray<T>)

    Check that the arrays are equivalent.

    Declaration
    public bool Equals(InplaceArray<T> other)
    Parameters
    Type Name Description
    InplaceArray<T> 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 IList to construct the array from.

    Returns
    Type Description
    InplaceArray<T>

    Corresponding InplaceArray from the input IList.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Argument out of range

    GetHashCode()

    Get a hashcode for the array.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    The hashcode of the InplaceArray.

    Overrides
    ValueType.GetHashCode()

    ToString()

    Returns a string representation of the array's elements.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    The string summary of the InplaceArray.

    Overrides
    ValueType.ToString()
    Exceptions
    Type Condition
    IndexOutOfRangeException

    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
    InplaceArray<T> lhs

    The first 'InplaceArray' to compare.

    InplaceArray<T> 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
    InplaceArray<T> lhs

    The first 'InplaceArray' to compare.

    InplaceArray<T> rhs

    The second 'InplaceArray' to compare.

    Returns
    Type Description
    bool

    Whether the arrays are not equivalent

    Implements

    IEquatable<T>
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)