[Issue 7287] New: std.container.BinaryHeap example fails
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 12 21:52:25 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7287
Summary: std.container.BinaryHeap example fails
Product: D
Version: D2
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: mailme+d at nilsb.dyndns.org
--- Comment #0 from Nils <mailme+d at nilsb.dyndns.org> 2012-01-12 21:52:21 PST ---
The example from http://www.dlang.org/phobos/std_container#BinaryHeap fails:
---
import std.algorithm, std.container;
void main() {
// Example from "Introduction to Algorithms" Cormen et al, p 146
int[] a = [ 4, 1, 3, 2, 16, 9, 10, 14, 8, 7 ];
auto h = heapify(a);
// largest element
assert(h.front == 16);
// a has the heap property
assert(equal(a, [ 16, 14, 10, 9, 8, 7, 4, 3, 2, 1 ]));
}
---
core.exception.AssertError at test(9): Assertion failure
Tested with dmd 2.057 and 2.058head.
Interestingly, the corresponding unit test in container.d differs slightly from
the example (and passes).
--
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