BinaryHeap as member
balddenimhero
balddenimhero at googlemail.com
Mon Nov 13 15:43:35 UTC 2017
On Monday, 13 November 2017 at 14:38:35 UTC, balddenimhero wrote:
> 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?
In case it helps, here is the functionality I'm trying to port to
D https://pastebin.com/CWAiEy40. I'm still struggling with
properly defining the member in D though.
More information about the Digitalmars-d-learn
mailing list