[Issue 10173] New: std.algorithm.remove should throw exception on wrong ordering of indices to remove

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 26 05:20:24 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10173

           Summary: std.algorithm.remove should throw exception on wrong
                    ordering of indices to remove
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: dmitry.olsh at gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2013-05-26 05:20:23 PDT ---
The following passage from documentation is not respected:
"""
Multiple indices can be passed into remove. In that case, elements at the
respective indices are all removed. The indices must be passed in increasing
order, otherwise an exception occurs.
"""

The following test asserts in remove for all 4 cases (r1-r4):

unittest
{
    import std.algorithm, std.range, std.stdio, std.typecons;
    int[] test = iota(0, 10).array;
    auto r1 = remove!(SwapStrategy.stable)(test, tuple(2, 4), tuple(1, 3));
    auto r2 = remove!(SwapStrategy.unstable)(test, tuple(2, 4), tuple(1, 3));
    auto r3 = remove!(SwapStrategy.stable)(test, 2, 4, 1, 3);
    auto r4 = remove!(SwapStrategy.unstable)(test, 2, 4, 1, 3);
}


Better yet remove may as well do reordering and merging of overlaping regions.
Depending on how this is solved it could become an enhancement request.

But at the very least Docs and code must be in sync.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list