-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Labels
Description
Original:
using System;
using System.Collections.Generic;
namespace Lsj.Util.Collections
{
public static class ArrayHelper
{
public static (T value, int row, int col)[] ToThreeValueTuples<T>(this T[][] array)
{
var result = new List<ValueTuple<T, int, int>>();
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array[i].Length; j++)
{
if (!array[i][j].Equals(default(T)))
result.Add((array[i][j], i, j));
}
}
return result.ToArray();
}
}
}ILSpy:
public static (T value, int row, int col)[] ToThreeValueTuples<T>(this T[][] array)
{
List<(T, int, int)> result = new List<(T, int, int)>();
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array[i].Length; j++)
{
ref readonly T reference = ref array[i][j];
T val = default(T);
if (val == null)
{
val = reference;
reference = ref val;
}
if (!reference.Equals(default(T)))
{
result.Add((array[i][j], i, j));
}
}
}
return result.ToArray();
}Reactions are currently unavailable