Say result1 and result2. I am using the code as follow which will exclude all the items that are in result2 from result1.
But it's talking too much time, since I have thousands of item on both list of int array. Is there any other approach with which I can achieve same efficiently? Appreciated!!
List result1 = new List { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 } };
List result2 = new List { new int[] { 1, 2, 3 }, new int[] { 7, 8, 9 } };
result2.ForEach(t => result1.RemoveAll(z => z.OrderBy(k=>k).SequenceEqual(t.OrderBy(k=>k))));

VulpesRank #55 · 29.2K reputationPosted Dec 2, 2012, 10:12 AM EST
VulpesRank #55 · 29.2K reputationPosted Dec 2, 2012, 9:44 AM EST
http://www.c-sharpcorner.com/Forums/Thread/193268/how-to-exclude-two-ilistint.aspx
or are you wanting two integers arrays to be regarded as equal if they contain the same elements, regardless of how they're ordered?
So {1, 2, 3} would be regarded as equal to {1, 3, 2}.
Deer Park39 reputationPosted Dec 2, 2012, 9:49 AM EST
Yes, the order of the integer array is not relevant in my case. So like you said {1, 2, 3} would be regarded as equal to {1, 3, 2}.
Any Suggestions or tips?
VulpesRank #55 · 29.2K reputationPosted Dec 2, 2012, 9:54 AM EST
If they can't, then using HashSets may be quicker.
Deer Park39 reputationPosted Dec 2, 2012, 10:04 AM EST
At this point I am not sure what other options I have.
Deer Park39 reputationPosted Dec 2, 2012, 11:08 AM EST
VulpesRank #55 · 29.2K reputationPosted Dec 2, 2012, 11:15 AM EST
You can then use the version of the code which doesn't sort the arrays in the Equals method.
My suspicion is that both the LINQ code and my version are sorting each array multiple times which will clearly slow things down. So just sorting the arrays the one time might help here.
Deer Park39 reputationPosted Dec 2, 2012, 12:18 PM EST
List
I guess it's just because the size of the list is too large.