You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TreeSubSet.Min and TreeSubSet.Max work incorrectly with custom comparer #54834
var comparer = Comparer<int>.Create((x, y) => x - y);
var set = new SortedSet<int>(new[]{1, 4}, comparer);
var view = set.GetViewBetween(1, 2);
Console.WriteLine(view.Max); // Prints 4 instead of 1
According to the documentation of IComparer.Compare() it can return any integer, not only [-1, 0, 1]. So this comparer should be ok.
Configuration
I run it on .net 5, but I think it is present in other versions as well.
Regression?
A similar issue was mentioned in 20474 (without comparer though). So I think it is regression.
Activity
eiriktsarpalis commentedon Jun 28, 2021
This seems like a bug introduced by dotnet/corefx#16771. It seems like a trivial fix, would you be willing to contribute a PR?
petrogavriluk commentedon Jun 28, 2021
I haven't contributed here yet, but yes, I can try.
Should I also add tests?
eiriktsarpalis commentedon Jun 28, 2021
Thanks, assigning the issue to you. A couple of tests reproducing your scenario for both min and max should suffice.
Please let me know if you have any questions on the dev workflow.
Fix incorrect comparison (dotnet#54834)
Fix incorrect comparison (#54834) (#55094)