incidental simplification

This commit is contained in:
Mathew Sutcliffe
2014-07-01 16:51:00 +01:00
parent a4b317b100
commit 63edca8ee8
3 changed files with 7 additions and 23 deletions

View File

@@ -43,12 +43,10 @@ namespace BlackMisc
*/
int CAudioDeviceList::count(CAudioDevice::DeviceType type) const
{
int c = 0;
foreach(CAudioDevice device, *this)
return std::count_if(this->begin(), this->end(), [type](const CAudioDevice &device)
{
if (device.getType() == type) c++;
}
return c;
return device.getType() == type;
});
}
/*

View File

@@ -86,19 +86,10 @@ namespace BlackMisc
*/
void CAirportList::removeIfOutsideRange(const Geo::CCoordinateGeodetic &position, const CLength &maxDistance, bool updateValues)
{
CLength d;
for (CAirportList::iterator i = begin(); i != end();)
this->removeIf([ & ](CAirport &airport)
{
d = i->calculcateDistanceAndBearingToPlane(position, updateValues);
if (maxDistance < d)
{
i = this->erase(i);
}
else
{
++i;
}
}
return airport.calculcateDistanceAndBearingToPlane(position, updateValues) > maxDistance;
});
}
} // namespace
} // namespace

View File

@@ -132,12 +132,7 @@ namespace BlackMisc
void CTextMessageList::toggleSenderRecipients()
{
if (this->isEmpty()) return;
for (int i = 0; i < this->size(); i++)
{
CTextMessage tm = (*this)[i];
tm.toggleSenderRecipient();
(*this)[i] = tm;
}
std::for_each(this->begin(), this->end(), [](CTextMessage &tm) { tm.toggleSenderRecipient(); });
}
} // namespace