-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AreCollectionsSame #814
Comments
you can easily create an extension method that does something like var seq1 = list1.OrderBy(t => t);
var seq2 = list2.OrderBy(t => t);
return seq1.SequenceEqual(seq2); or maybe var set1 = list1.ToHashSet();
var set2 = lits2.ToHashSet();
return set1.SetEquals(set2); |
@leandromoh I understand that I can, I actually created test for myself. I was just hoping to see the most efficient way in this library available for everyone.
[Benchmark]
[ArgumentsSource(nameof(Datasource))]
public bool SortThenCompare(TestSource source)
{
var x = source.XValues;
var y = source.YValues;
return x.OrderBy(t => t).SequenceEqual(y.OrderBy(l => l));
}
[Benchmark]
[ArgumentsSource(nameof(Datasource))]
public bool ConvertToHashset(TestSource source)
{
var x = source.XValues;
var y = source.YValues;
return x.ToHashSet().SetEquals(y.ToHashSet());
}
[Benchmark]
[ArgumentsSource(nameof(Datasource))]
public bool OneExceptAnother(TestSource source)
{
var x = source.XValues;
var y = source.YValues;
return !x.Except(y).Any() && !y.Except(x).Any();
} |
@Lonli-Lokli This has been implemented in SuperLinq, and will be released with v4.1.0 in the next few weeks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's pretty useful and widely used feature, to check if two unordered collections are the same, probably with default and nondefault comparers
The text was updated successfully, but these errors were encountered: