Creating a Priority Queue: An Adventure

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 5 05:14:28 PDT 2015


On 8/5/15 7:09 AM, "Per =?UTF-8?B?Tm9yZGzDtnci?= 
<per.nordlow at gmail.com>" wrote:
> On Wednesday, 5 August 2015 at 09:04:54 UTC, Nordlöw wrote:
>> This will however duplicate the underlying array aswell, which is
>> probably not what we want. How do we avoid this?
>
> Correction: the underlying storage array *must* be duplicated whenever
> we want to iterate over it without side effects in the original
> instance. That's just the way binary heaps work.

Yeah, I think there is no way to "traverse" a binary heap in order 
without manipulating it. However, you can print the underlying storage.

-Steve


More information about the Digitalmars-d-learn mailing list