Aug 18, 2016 at 11:09am UTC
I have this vector intersects, which stores the coordinates of intersection points (xyz-coordinates). Because I receive duplicates I want to erase this duplicates.
Normally I do this with this code:
1 2 3 4
std::vector<std::array<double , 3>> intersects;
std::sort(intersects.begin(), intersects.end(), sorting_intersects);
intersects.erase(std::unique(intersects.begin(), intersects.end()), intersects.end());
But here not all duplicates are erased. I also tried this code
1 2 3
std::set<array<double , 3>> set2(intersects.begin(), intersects.end());
intersects.erase(std::remove_if(intersects.begin(), intersects.end(), [&set2] (array<double , 3> item) {return !set2.erase(item); }), intersects.end());
But still there are some duplicates left.
Last edited on Aug 18, 2016 at 11:17am UTC
Aug 18, 2016 at 12:16pm UTC
Please post the definition of sorting_intersects
.