[Lemon-user] Some beginner confusion...
degski
degski at gmail.com
Mon Mar 30 09:12:12 CEST 2015
Would firstly like to thank the developper(s) of the lemon graph library
for this great library. I've been using it for a little while now... and I
think I've got the basics. There are some things unclear to me though...
and it's centred mostly around allocation (in memory).Consider the
following code-snippet:
lemon::ListDigraph dg1;
lemon::ListDigraph::Node n1 = dg1.addNode ( );
lemon::ListDigraph* dg2 ( new lemon::ListDigraph );
lemon::ListDigraph::Node n2 = dg2->addNode ( );
lemon::ListDigraph::Node* n3 = &dg2->addNode ( ); // warning: address
of temp taken! obviously the wrong thing to do.
Where are n1 and n2, respectively allocated (stack and heap?)... and what
are they, pointers, references or objects? Somewhere in the
user-list-archives there's a post asking about constructing large graphs,
with an advice to use the heap (case 2) and std::vector for (automatic)
memory management... When using dg2, does everything that is attached to it
(f.e. NodeMap) end up on the heap?
When doing:
lemon::ListDigraph::Node n1 = n2;
has anything happened to either graph? Is n1 now a copy of n2, or is it now
n2?
Sorry for my ignorance. Thanks in advance for any enlightenment offered!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20150330/2c44878b/attachment.html>
More information about the Lemon-user
mailing list