1
0
Fork 0

remove_if clean-ups while auditing :)

This commit is contained in:
James Turner 2018-01-12 20:06:08 +00:00
parent 1493c0adc8
commit b4cdac238e
3 changed files with 6 additions and 26 deletions

View file

@ -60,18 +60,6 @@ using std::endl;
namespace {
TrafficVectorIterator findTraffic(TrafficVector& vec, int id)
{
TrafficVectorIterator it = vec.begin();
for (; it != vec.end(); ++it) {
if (it->getId() == id) {
return it;
}
}
return it; // vec.end, effectively
}
void clearTrafficControllers(TrafficVector& vec)
{
TrafficVectorIterator it = vec.begin();
@ -843,22 +831,15 @@ void FGATCController::init()
}
}
class AircraftIsDead
void FGATCController::eraseDeadTraffic(TrafficVector& vec)
{
public:
bool operator()(const FGTrafficRecord& traffic) const
auto it = std::remove_if(vec.begin(), vec.end(), [](const FGTrafficRecord& traffic)
{
if (!traffic.getAircraft()) {
return true;
}
return traffic.getAircraft()->getDie();
}
};
void FGATCController::eraseDeadTraffic(TrafficVector& vec)
{
TrafficVector::iterator it = std::remove_if(vec.begin(), vec.end(), AircraftIsDead());
});
vec.erase(it, vec.end());
}

View file

@ -382,7 +382,7 @@ FGParkingList FGAirportDynamics::getParkings(bool onlyAvailable, const std::stri
FGParkingList result(parent()->groundNetwork()->allParkings());
GetParkingsPredicate pred(onlyAvailable, type, this);
FGParkingList::iterator it = std::remove_if(result.begin(), result.end(), pred);
auto it = std::remove_if(result.begin(), result.end(), pred);
result.erase(it, result.end());
return result;
}
@ -559,8 +559,7 @@ string FGAirportDynamics::fallbackGetActiveRunway(int action, double heading)
// discount runways based on cross / tail-wind
WindExclusionCheck windCheck(windHeading, windSpeed);
RunwayVec runways(parent()->getRunways());
RunwayVec::iterator it = std::remove_if(runways.begin(), runways.end(),
windCheck);
auto it = std::remove_if(runways.begin(), runways.end(), windCheck);
runways.erase(it, runways.end());
// sort highest scored to lowest scored

View file

@ -297,7 +297,7 @@ int FlightPlan::clearWayptsWithFlag(WayptFlag flag)
// now delete and remove
RemoveWithFlag rf(flag);
LegVec::iterator it = std::remove_if(_legs.begin(), _legs.end(), rf);
auto it = std::remove_if(_legs.begin(), _legs.end(), rf);
if (it == _legs.end()) {
return 0; // nothing was cleared, don't fire the delegate
}