Thread overview
[Issue 5049] New: std.algortihm.bringToFront() returns wrong value
Oct 13, 2010
Shin Fujishiro
Oct 14, 2010
Shin Fujishiro
Oct 15, 2010
Shin Fujishiro
October 13, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5049

           Summary: std.algortihm.bringToFront() returns wrong value
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: rsinfu@gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu@gmail.com> 2010-10-13 00:32:46 PDT ---
The doc states that bringToFront() returns the number of elements brought to the front, but it actually returns the number of swaps done:
--------------------
import std.algorithm, std.stdio;
void main()
{
    auto r = [4, 5, 6, 7, 0, 1, 2, 3];
    foreach (k; 0 .. r.length)
        writeln(bringToFront(r, r[k .. $]));
}
--------------------
% dmd -run test.d
0
7
6
7
4
7
6
7
--------------------

The output should be "0 7 6 5 4 3 2 1".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 14, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5049


Andrei Alexandrescu <andrei@metalanguage.com> changed:

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


--- Comment #1 from Andrei Alexandrescu <andrei@metalanguage.com> 2010-10-13 17:54:57 PDT ---
Good catch. Shin, feel free to take this over if you plan to fix it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 14, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5049


Shin Fujishiro <rsinfu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|andrei@metalanguage.com     |rsinfu@gmail.com


--- Comment #2 from Shin Fujishiro <rsinfu@gmail.com> 2010-10-14 11:04:28 PDT ---
All right, I'll fix it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5049


Shin Fujishiro <rsinfu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from Shin Fujishiro <rsinfu@gmail.com> 2010-10-15 10:58:08 PDT ---
Fixed in the svn trunk r2103.

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