checkpoint
This commit is contained in:
29
Gameboard.ShogiUI.BoardState/Array2D.cs
Normal file
29
Gameboard.ShogiUI.BoardState/Array2D.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Gameboard.ShogiUI.BoardState
|
||||
{
|
||||
public class Array2D<T> : IEnumerable
|
||||
{
|
||||
private readonly T[] array;
|
||||
private readonly int width;
|
||||
|
||||
public Array2D(int width, int height)
|
||||
{
|
||||
this.width = width;
|
||||
array = new T[width * height];
|
||||
}
|
||||
|
||||
public T this[int x, int y]
|
||||
{
|
||||
get => array[y * width + x];
|
||||
set => array[y * width + x] = value;
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => array.GetEnumerator();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user