mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #290 using a CRange of iterator adaptors in implementating the tertiary predicate-based methods of the derived containers,
but preserving the return-by-copy for API stability
This commit is contained in:
@@ -46,14 +46,20 @@ namespace BlackMisc
|
||||
return this->findBy(&CAtcStation::getCallsign, callsign);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find by callsigns
|
||||
*/
|
||||
CAtcStationList CAtcStationList::findByCallsigns(const CCallsignList &callsigns) const
|
||||
{
|
||||
return this->findBy(Predicates::MemberIsAnyOf(&CAtcStation::getCallsign, callsigns));
|
||||
}
|
||||
|
||||
/*
|
||||
* Find first by callsign
|
||||
*/
|
||||
CAtcStation CAtcStationList::findFirstByCallsign(const CCallsign &callsign, const CAtcStation &ifNotFound) const
|
||||
{
|
||||
CAtcStationList stations = findByCallsign(callsign);
|
||||
if (!stations.isEmpty()) return stations[0];
|
||||
return ifNotFound;
|
||||
return this->findByCallsign(callsign).frontOrDefault(ifNotFound);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -94,13 +100,7 @@ namespace BlackMisc
|
||||
*/
|
||||
CUserList CAtcStationList::getControllers() const
|
||||
{
|
||||
CUserList users;
|
||||
for (auto i = this->begin(); i != this->end(); ++i)
|
||||
{
|
||||
CAtcStation station = *i;
|
||||
if (station.getController().isValid()) users.push_back(station.getController());
|
||||
}
|
||||
return users;
|
||||
return this->findBy(Predicates::MemberValid(&CAtcStation::getController)).transform(Predicates::MemberTransform(&CAtcStation::getController));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user