Struct Array2D<T>
A 2-dimensional array backed by a flat array.
Implements
Namespace: GDX.Collections.Generic
Syntax
[VisualScriptingCompatible((short)1)]
public struct Array2D<T> : IDisposable
Type Parameters
Name | Description |
---|---|
T | Type of objects. |
Remarks
Mimics multi-dimensional array format.
Constructors
| Improve this Doc View SourceArray2D(Int32, Int32)
Create a Array2D<T>.
Declaration
public Array2D(int rowCount, int columnCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowCount | The number of rows (X). |
System.Int32 | columnCount | The number of columns (Y). |
Array2D(Int32, Int32, T[])
Create a Array2D<T> providing an existing arrayToUse
.
Declaration
public Array2D(int rowCount, int columnCount, T[] arrayToUse)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowCount | The number of rows (X). |
System.Int32 | columnCount | The number of columns (Y). |
T[] | arrayToUse | An existing array to use in the Array2D<T>. |
Fields
| Improve this Doc View SourceArray
The backing flat array.
Declaration
public T[] Array
Field Value
Type | Description |
---|---|
T[] |
ColumnCount
The length of each pseudo-array in the dataset.
Declaration
public int ColumnCount
Field Value
Type | Description |
---|---|
System.Int32 |
Remarks
CAUTION! Changing this will alter the understanding of the data.
RowCount
The number of pseudo-arrays created to support the dimensionality.
Declaration
public int RowCount
Field Value
Type | Description |
---|---|
System.Int32 |
Remarks
CAUTION! Changing this will alter the understanding of the data.
Properties
| Improve this Doc View SourceItem[Int32, Int32]
Get a typed object at a specific 2-dimensional index in Array.
Declaration
public T this[int x, int y] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The row/line number (vertical axis). |
System.Int32 | y | The column number (horizontal axis). |
Property Value
Type | Description |
---|---|
T |
Methods
| Improve this Doc View SourceAddColumns(Int32)
Add additional columns to the dataset.
Declaration
public void AddColumns(int numberOfNewColumns)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | numberOfNewColumns | The number of columns add. |
AddRows(Int32)
Add additional rows to the dataset.
Declaration
public void AddRows(int numberOfNewRows)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | numberOfNewRows | The number of rows/arrays to add. |
Dispose()
Properly dispose of the Array2D<T>.
Declaration
public void Dispose()
GetColumnIndex(Int32)
Get the column index of the provided index
.
Declaration
public int GetColumnIndex(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | A valid index contained within Array. |
Returns
Type | Description |
---|---|
System.Int32 | The column index. |
GetRowIndex(Int32)
Get the row index of the provided index
.
Declaration
public int GetRowIndex(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | A valid index contained within Array. |
Returns
Type | Description |
---|---|
System.Int32 | The row index. |
ReverseColumns()
Reverse the order of the columns in the backing Array.
Declaration
public void ReverseColumns()
ReverseRows()
Reverse the order of the rows in the backing Array.
Declaration
public void ReverseRows()
RotateClockwise()
Rotate internal dataset clockwise.
Declaration
public void RotateClockwise()
RotateCounterClockwise()
Rotate internal dataset counter-clockwise.
Declaration
public void RotateCounterClockwise()
ToMultiDimensionalArray()
Creates a copy of the internal array as a traditional multi-dimensional array.
Declaration
public T[, ] ToMultiDimensionalArray()
Returns
Type | Description |
---|---|
T[,] | A new copy of the backing Array in multi-dimensional form. |
Remarks
Useful for scenarios where fills need to be done with [,] structured multi-dimensional arrays.