Using std.container.BinaryHeap like C++

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 17 14:09:02 PDT 2014


On Sunday, 17 August 2014 at 18:54:27 UTC, Paulo Pinto wrote:
> Hi,
>
> I was wondering if it is possible to use the BinaryHeap store 
> like
> the C++'s make_heap/pop_heap/push_heap functions.
>
> I would like to port to D some A* C++ code I have which 
> rearranges the priorities on the underlying store, followed by 
> another
> make_heap() call on the vector used as store.
>
> Doing the same in D by calling again heapify() does not seem to 
> provide similar behavior.
>
> Just curious about it, as I don't plan to invest too much time 
> on it.
>
> Thanks,
> Paulo

AFAIK, D's BinaryHeap works just like C++'s 
make_heap/pop_heap/push_heap, except that it provides an actual 
object you can interface with, which has font, removeFront, 
removeAny and insert.

What exactly is the difference in behavior you are seeing? Just 
different results that can be attributed to implementation 
details, or fundamental differences?


More information about the Digitalmars-d-learn mailing list