std::vector<int>& delRepeat(std::vector<int>& nVector) { std::set<int> nTemp(nVector.begin(),nVector.end()); nVector.clear(); for (std::set<int>::iterator nIterator = nTemp.begin();nIterator != nTemp.end();nIterator++) nVector.push_back(*nIterator); return nVector; }
std::vector<int>& delRepeat(std::vector<int>& nVector) { std::vector<int> nTemp(nVector.begin(),nVector.end()); nVector.clear(); for (std::vector<int>::iterator nIterator = nTemp.begin();nIterator != nTemp.end();nIterator++) { if(std::find(nVector.begin(),nVector.end(),*nIterator) != nVector.end()) nVector.push_back(*nIterator); } return nVector; }
原文地址:http://wwhx27.blog.51cto.com/6807550/1631093