Reference or Value Semantics for Graph Traversal Range
Tobias Pankrath via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 18 05:53:16 PST 2015
On Wednesday, 18 February 2015 at 13:37:57 UTC, Nordlöw wrote:
> I've written a Dijkstra-style graph traversal range at
>
> https://github.com/nordlow/justd/blob/master/knet/traversal.d#L105
>
> that needs to internally store the AA distance map in member
> variable distMap.
>
> 1.
>
> All the data members except distMap have reference semantics.
I thought AAs had reference semantics.
> Therefore I've made my range a class instead of a struct. Is
> this the correct way to do it?
Neither false nor necessary. You could use a struct just as well.
> 2.
>
> To make it a ForwardRange I've also add a save() member. For
> now I've hardcoded the single member that needs to be duped. Is
> this correct way of doing it?
That's how I'd do it.
More information about the Digitalmars-d-learn
mailing list