I have a list that contains 1200 items,
I need to remove all of the duplicate items in the list that have a certain predicate, my items have the following status on them:
"not flat", "not covered", "accepted", X, Y, Z
i want to remove all duplicate item from the list that have the same X,Y,Z and have the same Status string
how can I achieve this?
I tried to do this this way:
public class MyEqualityComparer : IEqualityComparer<TcReportPoint3D>
{
public bool Equals(TcReportPoint3D a, TcReportPoint3D b)
{
return a.X == b.X && a.Y == b.Y && a.Z == b.Z && a.Status != b.Status;
}
public int GetHashCode(TcReportPoint3D other)
{
return other.X.GetHashCode() * 19 + other.Y.GetHashCode();
}
}
then:
//get all distinct values with different status
var points = reportpoints.Distinct(new MyEqualityComparer()).ToList();
//remove distinct values from the real least, hoping to remove duplicates.
foreach (var point in points)
{
if (point.Status == TePointStatus.NotCovered
|| point.Status == TePointStatus.OutOfSigma
|| point.Status == TePointStatus.NotFlat)
reportpoints.Remove(point);
}
The reason is that i have a list of items that was combined from a logic of two conditions, where the same value will have a different status then the other one.
I want to somehow be able to get the differences out of the list, then remove the duplicates that match the status.