Hi ALL
can any body help me by telling what will bw the Qt equivalent of std::vector.swap().
Thank you all.
Hi ALL
can any body help me by telling what will bw the Qt equivalent of std::vector.swap().
Thank you all.
Cheers,
Phillip
--- Please post the solution you got to solve your problem. It may help others.
Thanx. i went through the document. wat i found is qSwap() which can swap the tow passing element. but my requirment is replacement of std::vector.swap(vector element);
i ve stored some values. like
std::vector<int> vectelem;
int a;
int b;
vectelem.push_back(a);
vectelem.push_back(b);
swap(vectelem);
how to replace in Qt?
Cheers,
Phillip
--- Please post the solution you got to solve your problem. It may help others.
swap is not part of std::vector but is a separate algorithm. You can use it with QVector as well
Qt Code:
QVector<int> v; v.push_back(7); v.push_back(8); std::swap(v[0], v[1]);To copy to clipboard, switch view to plain text mode
By the way, I think your code is incorrect - you have to let swap() know which elements to swap. And you can use qSwap() as a replacement for swap().
Or maybe you wanted to use std::reverse()?
Qt Code:
QVector<int> v; v.push_back(7); v.push_back(8); std::reverse(v.begin(), v.end());To copy to clipboard, switch view to plain text mode
Bookmarks