BinaryHeap

Agustin agustin.l.alvarez at hotmail.com
Thu Nov 7 04:20:08 PST 2013


On Thursday, 7 November 2013 at 12:14:22 UTC, Agustin wrote:
> On Thursday, 7 November 2013 at 09:00:11 UTC, bearophile wrote:
>> Agustin:
>>
>>> I'm trying to use BinaryHeap and i found out that i cannot 
>>> use foreach(). My question is, there is any other way to do 
>>> it?, can i iterate a BinaryHeap?
>>
>> Please show the code :-)
>>
>> Perhaps you need to look at the head, pop the head item, look 
>> at the head, etc.
>>
>> Bye,
>> bearophile
>
>     BinaryHeap!(uint[]) heap;
>     foreach(type; heap)
>     {
>      ....
>     }
>
> no property 'popFront' for type 'BinaryHeap!(uint[])'

It seems that i need to have a pointer to the underlying array.

     uint[] intArray;
     BinaryHeap!(uint[]) heap;
     heap.acquire(intArray);
     foreach(int; intArray)
     {
      ....
     }


More information about the Digitalmars-d-learn mailing list