Min-Heap and Hash Table help

Henry Robbins Gouk henry.gouk at gmail.com
Mon Apr 2 19:36:42 PDT 2012


On Monday, 2 April 2012 at 23:42:45 UTC, Chris Pons wrote:
> On Monday, 2 April 2012 at 23:30:38 UTC, Justin Whear wrote:
>> On Tue, 03 Apr 2012 01:06:54 +0200, Chris Pons wrote:
>>
>>> Yes, I did see that. How would I set the predicate to sort by 
>>> fScore? An
>>> integer in my struct.
>>> 
>>
>> auto myHeap = BinaryHeap!`a.fScore > b.fScore`( rangeOfNodes );
>
> Ok, makes sense, will the heap be automatically sorted every 
> time I add a new item ? Might be a dumb question, but i'm going 
> to be removing and adding many nodes.

I haven't looked at the heap docs for Phobos, but the whole point
of a heap is that when you add/remove elements it remains in heap
order. In the case of a min-heap: the smallest node is at the
root and each child node is another heap in heap order.


More information about the Digitalmars-d-learn mailing list