Struct Array2DState<T>
- Namespace
- SwiftCollections
- Assembly
- SwiftCollections.dll
Represents the immutable state of a two-dimensional array, including its dimensions and underlying data.
[MemoryPackable(GenerateType.Object)]
public readonly struct Array2DState<T> : IMemoryPackable<Array2DState<T>>, IMemoryPackFormatterRegister
Type Parameters
TThe type of elements stored in the array.
- Implements
-
IMemoryPackable<Array2DState<T>>IMemoryPackFormatterRegister
- Inherited Members
Remarks
This struct is intended for scenarios where a snapshot of a 2D array's state is needed, such as serialization or state management. The data is stored in a one-dimensional array in row-major order. The struct is serializable and compatible with supported serialization frameworks.
Constructors
Array2DState(int, int, T[])
Initializes a new instance of the Array2DState class with the specified dimensions and data array.
[JsonConstructor]
[MemoryPackConstructor]
public Array2DState(int width, int height, T[] data)
Parameters
widthintThe number of columns in the two-dimensional array. Must be greater than zero.
heightintThe number of rows in the two-dimensional array. Must be greater than zero.
dataT[]The one-dimensional array containing the elements of the two-dimensional array, stored in row-major order. The length must be equal to width multiplied by height.
Fields
Data
Gets the underlying array of data elements contained in the collection.
[JsonInclude]
[MemoryPackInclude]
public readonly T[] Data
Field Value
- T[]
Height
Gets the height value represented by this field.
[JsonInclude]
[MemoryPackInclude]
public readonly int Height
Field Value
Width
Gets the width value represented by this field.
[JsonInclude]
[MemoryPackInclude]
public readonly int Width