Thread overview
[Issue 10173] New: std.algorithm.remove should throw exception on wrong ordering of indices to remove
May 26, 2013
Dmitry Olshansky
May 26, 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@puremagic.com
        ReportedBy: dmitry.olsh@gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh@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: -------
May 26, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10173


Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@erdani.com
         AssignedTo|nobody@puremagic.com        |andrei@erdani.com


--- Comment #1 from Andrei Alexandrescu <andrei@erdani.com> 2013-05-26 12:18:08 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1162

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 04, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10173


hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx


--- Comment #2 from hsteoh@quickfur.ath.cx 2013-09-04 08:05:15 PDT ---
Andrei's pull has been merged; has it solved this issue, or is there still more to be addressed?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 04, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10173



--- Comment #3 from hsteoh@quickfur.ath.cx 2013-09-04 08:07:35 PDT ---
Hmm, nevermind, just tested on git HEAD, it still asserts.

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