http://d.puremagic.com/issues/show_bug.cgi?id=5224
Summary: std.algorithm.remove!(SwapStrategy.unstable) doesn't work Product: D Version: D2 Platform: x86_64 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: ruzicic.aleksan...@gmail.com --- Comment #0 from Aleksandar Ruzicic <ruzicic.aleksan...@gmail.com> 2010-11-16 20:52:45 CET --- Example code below shows that there is a bug in remove() using unstable SwapStrategy - it removes wrong element from an array. Using default swap strategy works as expected. ----------------------------------------------------------- module test; import std.algorithm; import std.stdio, std.algorithm; void main(string[] args) { auto a = [1, 2, 3, 4]; print("initial", a); auto i = a.indexOf(3); writefln("indexOf(3) = %s", i); if (i > -1) { print("remove!(SwapStrategy.unstable)", remove!(SwapStrategy.unstable)(a, i)); } /* Tested with DMD v2.049 under Windows 7: > dmd -run test.d initial: 1 2 3 4 (length = 4) indexOf(3) = 2 remove!(SwapStrategy.unstable): 4 2 3 (length = 3) it removed element at index 0 rather than element at index 2 */ } void print(string name, int[] array) { writef("%s: ", name); foreach (elem; array) { writef("%s ", elem); } writefln("(length = %s)", array.length); } ----------------------------------------------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------