UTests pass with Pathfinder2D

This commit is contained in:
2021-02-28 07:52:28 -06:00
parent 715b328ef5
commit f55716d2ec
24 changed files with 687 additions and 294 deletions

View File

@@ -1,11 +1,12 @@
using System;
using PathFinding;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
namespace Gameboard.ShogiUI.BoardState
{
public class Array2D<T> : IEnumerable<T>
public class Array2D<T> : IPlanarCollection<T>, IEnumerable<T>
{
/// <returns>False to stop iterating.</returns>
public delegate void ForEachDelegate(T element, int x, int y);
@@ -31,6 +32,13 @@ namespace Gameboard.ShogiUI.BoardState
set => array[(int)y * width + (int)x] = value;
}
public int GetLength(int dimension) => dimension switch
{
0 => width,
1 => height,
_ => throw new IndexOutOfRangeException()
};
public void ForEach(ForEachDelegate callback)
{
for (var x = 0; x < width; x++)