www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18634] New: RBTree does not work with delegate comparators

https://issues.dlang.org/show_bug.cgi?id=18634

          Issue ID: 18634
           Summary: RBTree does not work with delegate comparators
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: trivial
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: viktor.ivanov gmail.com

The RedBlackTree does not work with delegate comparators due to
RedBlackTree.opEquals() forcing a function when doing the equality comparison.

The following test shows the issue:

    import std.algorithm.comparison : equal;

    auto t = new RedBlackTree!(int, delegate (a, b) => a > b);
    t.insert([1, 3, 5, 4, 2]);
    assert(t[].equal([5, 4, 3, 2, 1]));

--
Mar 19 2018