[Issue 3946] New: schwartzSort - SwapStrategy always unstable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Mar 13 00:41:35 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3946
Summary: schwartzSort - SwapStrategy always unstable
Product: D
Version: 2.041
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: 9il at rambler.ru
--- Comment #0 from Ilya Yaroshenko <9il at rambler.ru> 2010-03-13 00:41:34 PST ---
In the last line sort calling without "ss" (SwapStrategy) - it is looks like
always unstable:
module std.algorithm;
void schwartzSort(alias transform, alias less = "a < b",
SwapStrategy ss = SwapStrategy.unstable, Range)(Range r)
if (isRandomAccessRange!(Range) && hasLength!(Range))
{
alias typeof(transform(r.front)) XformType;
auto xform = new XformType[r.length];
foreach (i, e; r)
{
xform[i] = transform(e);
}
auto z = zip(xform, r);
alias typeof(z.front()) ProxyType;
bool myLess(ProxyType a, ProxyType b)
{
return binaryFun!(less)(a.at!(0), b.at!(0));
}
sort!(myLess)(z); /// <-------------
}
--
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