Hi ALL
can any body help me by telling what will bw the Qt equivalent of std::vector.swap().
Thank you all.
Printable View
Hi ALL
can any body help me by telling what will bw the Qt equivalent of std::vector.swap().
Thank you all.
Take a look at QtAlgorithms.
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?
swap is not part of std::vector but is a separate algorithm. You can use it with QVector as well
Code:
QVector<int> v; v.push_back(7); v.push_back(8); std::swap(v[0], v[1]);
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()?
Code:
QVector<int> v; v.push_back(7); v.push_back(8); std::reverse(v.begin(), v.end());