remove the need for IntArrayHelper.cs; support conversion from type[][] and type[,] to std::vector<std::vector<type>> in C#

This commit is contained in:
Laurent Perron
2019-05-06 12:55:30 +02:00
parent 98ff9989c9
commit a70ed70563
13 changed files with 105 additions and 147 deletions

View File

@@ -35,6 +35,23 @@ public static class NestedArrayHelper
return flat;
}
public static T[] GetFlatArrayFromMatrix<T>(T[,] arr)
{
int flatLength = arr.GetLength(0) * arr.GetLength(1);
int idx = 0;
T[] flat = new T[flatLength];
for (int i = 0; i < arr.GetLength(0); i++)
{
for (int j = 0; j < arr.GetLength(1); j++)
flat[idx++] = arr[i, j];
}
return flat;
}
public static int[] GetArraySecondSize<T>(T[][]arr)
{
var result = new int[arr.GetLength(0)];