Creating a growable binary heap or priority queue using Phobos?
SimonM
user at example.net
Sun Nov 13 22:17:43 PST 2011
On 2011/11/14 02:10 AM, bearophile wrote:
> SimonM:
>
>> 2009, 27 April:
>> http://www.digitalmars.com/d/archives/digitalmars/D/std.algorithm.BinaryHeap_88811.html
>
> See the working version:
> http://rosettacode.org/wiki/Huffman_coding#D
>
> Bye,
> bearophile
Okay, I looked at the example, and it seems that the only reason it
works is because that piece of code never requires the array's length to
grow larger than it's initial length (at the start of the loop, 2
elements are taken out, and at the end, only one is inserted back in).
If I try using a BinaryHeap with a range, then, like the documentation
mentions, I can't grow that BinaryHeap any larger than it's initial
size, because I got the following error: "Cannot grow a heap created
over a range". But somehow I can't get it working with an Array!(T) like
the documentation implies it should be capable of?
More information about the Digitalmars-d-learn
mailing list