[Issue 6956] New: std.algorithm.remove problem with SwapStrategy.unstable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Nov 15 16:39:18 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6956
Summary: std.algorithm.remove problem with
SwapStrategy.unstable
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2011-11-15 16:38:31 PST ---
This is a spin off of bug 6849. Problem partially found by Steven
Schveighoffer.
import std.stdio, std.algorithm;
void main() {
int[] data1 = [10, 20, 30, 40];
writeln(remove(data1, 1));
writeln(data1);
int[] data2 = [10, 20, 30, 40];
writeln(remove!(SwapStrategy.unstable)(data2, 1));
writeln(data2);
}
Output, DMD 2.057head:
[10, 30, 40]
[10, 30, 40, 40]
[40, 20, 30]
[40, 20, 30, 40]
So with SwapStrategy.unstable it seems index 0 was removed, not index 1.
Expected output:
[10, 30, 40]
[10, 30, 40, 40]
[10, 40, 30]
[10, 40, 30, 40]
--
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