30 lines
613 B
C#
30 lines
613 B
C#
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();
|
|
}
|
|
}
|