ネストされたint[]
座標に座標 x、y が含まれている場合、SequenceEqual を使用してそれらを比較するにはどうすればよいですか?
リストは座標のグループです。他のすべてのリストをチェックして、同じ数の座標と同じ座標値があるかどうかを確認したいと思います。両方が一致する場合は、冗長なものを削除したいと思います。それ以外の場合は、そのままにしてください。
private List<List<int[]>> combineList(List<List<int[]>> matches){
Debug.Log (matches.Count());
foreach(List<int[]> tileGroup in matches){
foreach(List<int[]> other in matches){
if(other == tileGroup) continue;
if(sequenceEqual(tileGroup, other)){
matches.Remove(other);
}
}
}
Debug.Log (matches.Count());
return matches;
}
private bool sequenceEqual(List<int[]> groupA, List<int[]> groupB){
if(groupA.Count() == groupB.Count()){
int i = 0, j = 0;
Dictionary<int, int[]> dictA = new Dictionary<int, int[]>(),
dictB = new Dictionary<int, int[]>();
foreach(int[] coordinate in groupA){
dictA.Add (i, coordinate);
i++;
}
foreach(int[] coordinate in groupB){
dictB.Add (j, coordinate);
j++;
}
return dictA.Values.SequenceEqual(dictB.Values);
}
return false;
}