www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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



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
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
May 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10173


hsteoh quickfur.ath.cx changed:

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



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: -------
Sep 04 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10173




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: -------
Sep 04 2013