Whats wrong with binery heap or i am not understand something?
AlexM
alexm999 at gmail.com
Thu Apr 2 12:59:06 UTC 2020
Please explain me whats wrong with binery heap?!!!
Simple example:
import std.container.binaryheap;
import std.stdio;
void main()
{
int[] a = [ 4, 1, 3, 2, 16, 9, 10, 14, 8, 7 ];
int[] b = new int[a.length];
auto h = BinaryHeap!(int[], "a > b")(b, 0);
foreach (e; a)
{
h.insert(e);
}
writeln(b); // [1, 2, 3, 4, 7, 9, 10, 14, 8, 16]
writeln(h); // [1, 2, 3, 4, 7, 8, 9, 10, 14, 16]
writeln(h.length); // 0 ???????
h.insert(21);
writeln(h); // [21] ????????
writeln(h.length); // 0 ???????
}
More information about the Digitalmars-d-learn
mailing list