[Lemon-devel] Quiz (good to know)

Balazs Dezso deba at inf.elte.hu
Wed Nov 19 16:12:10 CET 2008


Hi

I have an idea: 
1) Reallocate the storage area according to the current number of elements in 
the vector. /// \post v.size() == v.capacity()
2) Emptying the vector with deallocation of the storage area. /// \post 
v.capacity() == 0

I hope, that I'm the winner! :)

Best, Balazs


On Wednesday 19 November 2008 12:44:49 Alpár Jüttner wrote:
> Hi,
>
> I learned something interesting and useful from Akos yesterday. Let me
> share it with you (in a form of a question).
>
> Assume we have a vector,, for example like this:
>
> std::vector<int> v(100000);
>
> Then what will the following expression do? What is its use?
>
> std::vector<int>(v).swap(v);
>
> And what about this one?
>
> std::vector<int>().swap(v);
>
> I offer a Turo Rudi (or some locally available equivalent) for the fist
> solver.
>
> Best regards,
> Alpar
>
> _______________________________________________
> Lemon-devel mailing list
> Lemon-devel at lemon.cs.elte.hu
> http://lemon.cs.elte.hu/mailman/listinfo/lemon-devel




More information about the Lemon-devel mailing list