BinaryHeap as member

balddenimhero balddenimhero at googlemail.com
Mon Nov 13 14:38:35 UTC 2017


I need a priority queue of integers whose elements are not 
ordered by the default `opCmp` but some delegate.

The following gist illustrates the problem I'm having:
https://run.dlang.io/gist/92876b2c4d8c77cdc68f1ca61e7e8e44?compiler=dmd

The `Foo` class is supposed to wrap a binary heap (to be used as 
priority queue) and order its contents according to `o.isLess`. 
However I do not manage to initialise the according member 
variable.

Obviously, with the `h` member having type `BinaryHeap(int[], 
"a<b")` and the constructor trying to assign a 
`BinaryHeap!(int[], f)` the types do not quite match (line 18).

Maybe I'm missing something obvious or approaching this in the 
wrong way. Do you have any suggestions on how to achieve the 
desired result?


More information about the Digitalmars-d-learn mailing list