[Lemon-user] EdgeMap copy constructor

Peter Vizi peter.vizi at itk.ppke.hu
Mon Nov 8 14:45:49 CET 2010


Alpar,

Thank you for your response.

On 11/06/2010 08:59 PM, Alpár Jüttner wrote:
> > As far as I know, the C++ standard only allows default constructible
> > data type as the template parameter of std::vector<>, so EdgeMaps
> > couldn't have been used anyway.
This is not the case, vector[1] does not impose such requirement for its
contained type. You can give a default value for the constructor of
vector, and it will be copied n times, or you can give your own
Allocator as well.

> > The fundamental problem with using EdgeMaps (and basically any other BIG
> > datastructures) together with std::vector<> is that the latter one
> > copies its elements from time to time, which results in copying huge
> > chunks of memory.
You are correct, vector will copy a lot of memory if your objects are
big in this sense, but it should be a *user's* decision to do this or not.

> > I suggest using
> >
> > std::vector< lemon::ListGraph::EdgeMap< bool > * >
> >
> > and manually allocating and de-allocating the components with new and
> > delete. A bit cumbersome but works.
Unfortunately I am forced to do this, and also to manually copy each
EdgeMap with a loop. Bottom line: memory is still copied but not as
conveniently as with a copy constructor.

If you still think EdgeMap shouldn't be copyable you should have a
conceptual reason for this: I'm not that familiar with the library to
judge this from this point of view, but in my opinion your memory
argument is not strong enough.

Regards.
Peter

[1] http://www.sgi.com/tech/stl/Vector.html

-- Peter Vizi Ph.D. student Faculty of Information Technology Pazmany
Peter Catholic University

	
Peter Vizi <peter.vizi at itk.ppke.hu>
Ph.D. Student
Faculty of Information Technology
Peter Pazmany Catholic University
-------------- next part --------------
A non-text attachment was scrubbed...
Name: peter_vizi.vcf
Type: text/x-vcard
Size: 309 bytes
Desc: not available
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20101108/55a2130f/attachment.vcf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20101108/55a2130f/attachment.asc>


More information about the Lemon-user mailing list