Bug 6066 – std.container: BinaryHeap interface is broken.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-05-28T03:05:00Z
Last change time
2013-02-11T23:13:38Z
Assigned to
andrei
Creator
timon.gehr
Comments
Comment #0 by timon.gehr — 2011-05-28T03:05:00Z
From my code:
auto h=BinaryHeap!(typeof(s),"a.y<b.y")(s);
The two argument's order is reverse: the compiler can always infer the type but hardly the comparison predicate.
That the "convenience function" heapify does not take an optional comparison predicate does not make things any better.
Ideally, it should be possible to write:
auto h=heapify!"a.y<b.y"(s);
(As is consistent with Eg. sort.)
Therefore:
1. Ideally, the order of the two arguments for BinaryHeap should change.
2. heapify _really_ should take a comparison predicate as its first template argument. This won't break code, because no sane D developer has explicitly passed the type to heapify.