So in my code I got a vector of multidimensional arrays. In this vector I store the coordinates of points of a contour. Before I can restore the contour, based on the points, I have to erase the duplicates to reduce the data. So I found that I can use std::unique
, if the vector is sorted. But sorting isn't needed, so I want to erase the duplicates from the unsorted vector. So I have to use std::set
to remove the duplicates
std::vector<std::array<double, 3>> matrix;
rows = 2*lss.size();
matrix.resize(rows);
int j=0;
for(size_t i = 0;i<lss.size();i++) {
int k = j+1;
matrix[j][0]=lss[i].v[0].x;
matrix[j][1]=lss[i].v[0].y;
matrix[j][2]=lss[i].v[0].z;
matrix[k][0]=lss[i].v[1].x;
matrix[k][1]=lss[i].v[1].y;
matrix[k][2]=lss[i].v[1].z;
j=j+2;
}
std::set<double> set(matrix.begin(), matrix.end());
matrix.erase(std::remove_if(matrix.begin(), matrix.end(), [&set] (double item) {return !set.erase(item); }), matrix.end());
But for the line std::set<double> set(matrix.begin(), matrix.end());
I get this error message: 'std::pair<_Ty1,_Ty2> std::set<_Kty>::insert(double &&) : cannot convert parameter 1 from std::array<_Ty,_Size> to 'double &&'
.
For the following line I also receive an error message: 'bool export::<lambda_c894aac2078f37151750793b2c6d0417>::operator ()(double) const' : cannot convert parameter 1 from 'std::array<_Ty,_Size>' to 'double'