1.删除一个vector中的重复元素:
struct ST_MY
{
int m_nID;
int m_nType;
bool operator < ( const ST_MY& oMY ) const
{
return m_nID < oMy.m_nID;
}
}
class CCompEqual
{
bool operator() ( ST_MY& oMY1, ST_MY& oMY2 )
{
return oMY1.m_nID == oMY2.m_nID;
}
}
vector< ST_MY > vctOp;
sort( vctOp.begin(), vctOp.end() );
vector< ST_MY >::iterator it = unique( vctOp.begin(), vctOp.end(), CCompEqual() );
vctOp.erase( it, vctOp.end() );
阅读(1284) | 评论(0) | 转发(0) |