Skip to content

Regression in SortedSet::Max #20474

Closed
Closed

Description

@marek-safar

introduced in dotnet/corefx#11968

using System;
using System.Collections.Generic;

class X
{
	public static void Main ()
	{

		var set = new SortedSet<int> { 1, 3, 5, 7, 9 };
		var view = set.GetViewBetween (4, 8);

		Console.WriteLine (view.Max); // Prints 9 instead of 7
	}
}

Activity

  1. stephentoub commented on Mar 6, 2017

    @stephentoub
    Member
  2. mjp41 commented on Mar 6, 2017

    @mjp41
    Member

    Sorry. So the previous code for Min and Max was using InOrderTreeWalk, which got overridden by TreeSubset.

    There look like there are three possible fixes,

    1. write a custom Min and Max for TreeSubSet,
    2. use the old version from Min and Max, from before my change, in TreeSubSet, or
    3. revert completely, and take the extra allocation, for Min and Max.

    Can/should subclasses depend on Min and Max calling InOrderTreeWalk? It is internal, so as long as we find all subclasses in CoreFX then it should be okay to do 1 or 2. I am happy to do 1 or 2.

    2 is the simplest, 1 would be the most optimal. What is the time line for needing the fix?

  3. stephentoub commented on Mar 6, 2017

    @stephentoub
    Member

    What is the time line for needing the fix?

    Relatively soon :)

    There look like there are three possible fixes

    Let's do whichever strikes a decent balance between not being too much worse on perf and minimizing the chance of further regression. Sounds like that's 2?

  4. transferred this issue fromdotnet/corefxon Jan 31, 2020
  5. added this to the 2.0.0 milestone on Jan 31, 2020
  6. ghost locked as resolved and limited conversation to collaborators on Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions