CSplinePathExtra: Collapse RemoveWaypoint loop into find_if()
This commit is contained in:
parent
487f2ae176
commit
8c06309364
|
@ -64,16 +64,15 @@ void CSplinePathExtra::AddWaypoints()
|
|||
}
|
||||
}
|
||||
|
||||
void CSplinePathExtra::RemoveWaypoint(CWaypointExtra *pWaypoint)
|
||||
void CSplinePathExtra::RemoveWaypoint(const CWaypointExtra *pWaypoint)
|
||||
{
|
||||
for (auto it = mWaypoints.begin(); it != mWaypoints.end(); ++it)
|
||||
{
|
||||
if (*it == pWaypoint)
|
||||
{
|
||||
mWaypoints.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const auto iter = std::find_if(mWaypoints.cbegin(), mWaypoints.cend(),
|
||||
[pWaypoint](const auto* entry) { return entry == pWaypoint; });
|
||||
|
||||
if (iter == mWaypoints.cend())
|
||||
return;
|
||||
|
||||
mWaypoints.erase(iter);
|
||||
}
|
||||
|
||||
void CSplinePathExtra::ClearWaypoints()
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
void FindAttachedWaypoints(std::set<CWaypointExtra*>& rChecked, CWaypointExtra* pWaypoint);
|
||||
void AddWaypoints();
|
||||
void RemoveWaypoint(CWaypointExtra* pWaypoint);
|
||||
void RemoveWaypoint(const CWaypointExtra* pWaypoint);
|
||||
void ClearWaypoints();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue