[Issue 7125] New: semi stable sort is not supported
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 17 05:33:39 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7125
Summary: semi stable sort is not supported
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2011-12-17 05:33:37 PST ---
Following code does not compile,
import std.algorithm;
void main()
{
auto r1 = sort!("a<b", SwapStrategy.unstable)([1,3,2,4]);
assert(equal(r1, [1,2,3,4]));
auto r2 = sort!("a<b", SwapStrategy.semistable)([1,3,2,4]); // Line 7
assert(equal(r2, [1,2,3,4]));
auto r3 = sort!("a<b", SwapStrategy.stable)([1,3,2,4]);
assert(equal(r3, [1,2,3,4]));
}
Output:
C:\dmd2\src\phobos\std\algorithm.d(7001): Error: static assert
(cast(SwapStrategy)1 != cast(SwapStrategy)1) is false
C:\dmd2\src\phobos\std\algorithm.d(6710): instantiated from here:
sortImpl!(result,ss,int[])
test.d(7): instantiated from here:
sort!("a<b",cast(SwapStrategy)1,int[])
Semi-stable sort is stable sort.
So if stable sort is supported, we can implement it with stable sort, at least.
--
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