小编Jua*_*nti的帖子

确定向量中是否有重复项

我想确定向量中是否存在重复项。这里最好的选择是什么?

sort(arrLinkToClients.begin(), arrLinkToClients.end(), [&](const type1& lhs,const type1& rhs)
{
    lhs.nTypeOfLink < rhs.nTypeOfLink;
});

auto it = unique(arrLinkToClients.begin(), arrLinkToClients.end(), [&](const type1& lhs, const type1& rhs)
{
    lhs.nTypeOfLink == rhs.nTypeOfLink;
});

//how to check the iterator if there are duplicates ?
if (it)
{
  //
}
Run Code Online (Sandbox Code Playgroud)

c++ stl vector unique

1
推荐指数
1
解决办法
2184
查看次数

标签 统计

c++ ×1

stl ×1

unique ×1

vector ×1