Creating a Priority Queue: An Adventure
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Aug 4 19:26:46 PDT 2015
On Wednesday, 5 August 2015 at 01:27:53 UTC, Steven Schveighoffer
wrote:
> On 8/4/15 9:02 PM, DarthCthulhu wrote:
>
>> writefln("PQ: %s", pq.queue); <- prints PQ: [Tuple!(int,
>> string)(3,
>> "HELLO3"), Tuple!(int, string)(10, "HELLO10"), Tuple!(int,
>> string)(11,
>> "HELLO11")]
>
> This is probably consuming your queue, popping all the data off
> as it prints. If you print the length before hand, I'll bet
> it's not zero.
>
> I don't know how to print the elements without removing them,
> as binary heap doesn't have a range type, it seems to be the
> range itself (an odd situation). Perhaps print the underlying
> storage?
>
> -Steve
It looks like there was a breaking change made to BinaryHeap
somewhere between 2.065 and the present. The code compiles fine
on 2.065.
http://dpaste.dzfl.pl/65ba735d69e7
More information about the Digitalmars-d-learn
mailing list