Problem Instantiating a BinaryHeap with a Comparison Function the needs this

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 19 15:26:56 PST 2015


On Thursday, 19 February 2015 at 14:12:51 UTC, Tobias Pankrath 
wrote:
> On Thursday, 19 February 2015 at 11:56:19 UTC, Nordlöw wrote:
>
> Please provide reduced examples.
>
> This fails:
>
> class C
> {
>     int[] a;
>     alias BH = BinaryHeap!(int[], (x, y) => (x+a < y));
> }
>
> This works:
>
> class C
> {
>     int[] a;
>
>     void foo() {
>         alias BH = BinaryHeap!(int[], (x, y) => (x+a < y));
>     }
> }
>
> But will create an instance of BinaryHeap per member function.
>
>> What to do?
>
> Dunno.

I modified my algorithm to be more like

http://rosettacode.org/wiki/Dijkstra%27s_algorithm#D

which doesn't require a special comparison function for 
RedBlackTree.

See update at:

https://github.com/nordlow/justd/blob/master/knet/traversal.d#L108

Thanks anyway.


More information about the Digitalmars-d-learn mailing list