I have a three-dimensional point vector represented by a class Point3D,
std::vector<Point3D> points;
I also have a vector size_tcontaining the indices of the vector points,
std::vector<size_t> indices_true;
Now I want to build an inversion indices_true, i.e. I want to create another pointer vector indices_falsecontaining all the indexes that are not in indices_true. How can this be done faster than the following:
for (size_t i = 0; i < points.size(); i++)
{
// TODO: The performance of the following is awful
if (std::find(indices_true.begin(), indices_true.end(), i) == indices_true.end())
indices_false.push_back(i);
}
source
share