[Lemon-user] EdgeMap copy constructor
Alpár Jüttner
alpar at cs.elte.hu
Sat Nov 6 20:59:53 CET 2010
Hi,
On Sat, 2010-11-06 at 01:43 +0100, Peter Vizi wrote:
> Dear Users,
>
> In my application I have to create a bunch of lemon::ListGraph::EdgeMap<
> bool > objects, and I have to pass it around for other objects to use.
> For a container I chose to use one std::vector<
> lemon::ListGraph::EdgeMap< bool > >.
>
> My problem comes from the fact that the copy constructor of
> lemon::ListGraph::EdgeMap< bool > is private, hence the push_back
> function call will result in a compile time error.
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.
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.
> As I understand the
> way to create "copies" of such edge maps would be to use a
> lemon::GraphCopy object, but this is not applicable for the push_back call.
>
> Anyone can suggest a workaround for this problem?
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.
Regards,
Alpar
>
> Regards,
> Peter
>
> _______________________________________________
> 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