[Lemon-user] Copy constructors
Alpár Jüttner
alpar at cs.elte.hu
Tue Feb 23 17:54:39 CET 2010
Hi,
One more think you might find useful. Even if EdgeMap<> had default and
copy constructors, using
std::vector<lemon::ListGraph::EdgeMap<float> > edgeCostVec;
would not probably be a good idea. The problem is that when you enlarge
an std::vector<>, it copies all its elements from time to time. It
results in copying the full EdgeMap<>s, which are typically large data
structures.
To the contrary,
std::vector<lemon::ListGraph::EdgeMap<float>* > edgeCostVec;
copies the pointers only, the maps themselves remain in place.
Regards,
Alpar
On Tue, 2010-02-23 at 07:15 -0800, D Haley wrote:
> Hello again,
>
> I am having more troubles with edgemaps (thanks for the prev. help, worked a treat). Due to the library interface, the copy constructors are private for edgemaps, which seem to prevent me assigning or dupliating them in any way. Is there a way I can do something like the following? I'm currently dropping to pointer semantics, but it feels like a kludge.
>
> vector<lemon::ListGraph> g;
> vector<lemon::ListGraph::EdgeMap<float> > edgeCostVec;
>
> makeSomeGraphs(g); //pass-by-ref (non-const)
>
> edgeCostVec[ui].resize(g.size());
> for(unsigned int ui=0;ui<g.size(); ui++)
> edgeCostVec[ui] = (lemon::ListGraph::EdgeMap<float>(g[ui]));
>
>
>
>
> _______________________________________________
> Lemon-user mailing list
> Lemon-user at lemon.cs.elte.hu
> http://lemon.cs.elte.hu/mailman/listinfo/lemon-user
More information about the Lemon-user
mailing list