Hi, I hope you can help me out on this one.
I have a List < List < double[] > > and I want to remove everything which is duplicate in such list. That is:
1) Within the List < double[] > there are some of the double[] which are duplicate.I want to keep only the non-duplicate doubles[] within the List < double[] >.
2) Within List < List < double[] > > there are some of the List < double[] > which are duplicate. I want to keep only the non-repeated lists.
I have tried the following but it doesn't work.
Java
public static List<List<double[]>> CleanListOfListsOfDoubleArray(List<List<double[]>> input)
{
var output = new List<List<double[]>>();
for (int i = 0; i < input.Count; i++)
{
var temp= input[i].Distinct().ToList();
output.Add(temp);
}
return output.Distinct().ToList();
}Any suggestions?
Many thanks!!!

HappyCode HappyCode75 pointsPosted Jun 24, 2015, 8:27 AM EDT
public class ArrayComparer<T> : IEqualityComparer<T[]> { public bool Equals(T[] x, T[] y) { return ReferenceEquals(x, y) || (x != null && y != null && x.SequenceEqual(y)); } public int GetHashCode(T[] obj) { return 0; } } public class ListOfArrayComparer<T> : IEqualityComparer<List<T[]>> { public bool Equals(List<T[]> x, List<T[]> y) { return ReferenceEquals(x, y) || (x != null && y != null && x.SequenceEqual(y, new ArrayComparer<T>())); } public int GetHashCode(List<T[]> obj) { return 0; } }public static List<List<double[]>> CleanListOfListsOfDoubleArray(List<List<double[]>> input) { var output = new List<List<double[]>>(); for (int i = 0; i < input.Count; i++) { var temp = input[i].Distinct(new ArrayComparer<double>()).ToList(); output.Add(temp); } return output.Distinct(new ListOfArrayComparer<double>()).ToList(); }public static List<List<double[]>> CleanListOfListsOfDoubleArray(List<List<double[]>> input) { var output = input.Select(t => t.Distinct(new ArrayComparer<double>()).ToList()).ToList(); return output.Distinct(new ListOfArrayComparer<double>()).ToList(); }