// Disclaimer: there might be some minor syntactic errors in this
// First define this functor (could also be a function, if parent can be accessed globally, which I'd be concerned about)
struct CheckInBounds
{
Parent* parent; // Or whatever type "parent" really is
CheckInBounds(Parent* p) : parent(p) {
}
bool operator()(const GameObject* o) {
if (!inBounds(o->getX(), o->getY())) {
parent->addObject(o);
return true; // remove it
}
else {
return false; // don't remove it
}
}
};
// Then, you can do something simple like this:
auto newEnd = std::remove_if(objects.begin(), objects.end(), CheckInBounds(parent));
objects.erase(newEnd, objects.end());
Problem with my Quadtree - converting from std::vector to std::set
Note that it might be simpler to do something like this:
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement