docs.unity3d.com
    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.

    Inherited Members
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: Unity.MLAgents
    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

    Item[Int32]

    Per-element access.

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

    Length

    The length of the array.

    Declaration
    public readonly int Length { get; }
    Property Value
    Type Description
    Int32

    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
    Boolean

    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
    Boolean

    Whether the arrays are not equivalent

    Implements
    IEquatable<T>.Equals(T)

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

    Equality(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
    Boolean

    Whether the arrays are equivalent.

    Inequality(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
    Boolean

    Whether the arrays are not equivalent

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023