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
    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

    InplaceArray(T, T)

    Create a length-2 array.

    Declaration
    public InplaceArray(T elem0, T elem1)
    Parameters
    Type Name Description
    T elem0
    T elem1

    InplaceArray(T, T, T)

    Create a length-3 array.

    Declaration
    public InplaceArray(T elem0, T elem1, T elem2)
    Parameters
    Type Name Description
    T elem0
    T elem1
    T elem2

    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
    T elem1
    T elem2
    T elem3

    Properties

    this[int]

    Per-element access.

    Declaration
    public T this[int index] { get; set; }
    Parameters
    Type Name Description
    int index
    Property Value
    Type Description
    T
    Exceptions
    Type Condition
    IndexOutOfRangeException

    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
    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
    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
    Returns
    Type Description
    InplaceArray<T>
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    GetHashCode()

    Get a hashcode for the array.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()

    ToString()

    Returns a string representation of the array's elements.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()
    Exceptions
    Type Condition
    IndexOutOfRangeException

    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
    InplaceArray<T> rhs
    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
    InplaceArray<T> rhs
    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)