mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +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:
@@ -47,14 +47,20 @@ namespace BlackMisc
|
||||
return this->findBy(&CAircraft::getCallsign, callsign);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find by callsigns
|
||||
*/
|
||||
CAircraftList CAircraftList::findByCallsigns(const CCallsignList &callsigns) const
|
||||
{
|
||||
return this->findBy(Predicates::MemberIsAnyOf(&CAircraft::getCallsign, callsigns));
|
||||
}
|
||||
|
||||
/*
|
||||
* Find by callsign
|
||||
*/
|
||||
CAircraft CAircraftList::findFirstByCallsign(const CCallsign &callsign, const CAircraft &ifNotFound) const
|
||||
{
|
||||
CAircraftList aircrafts = this->findByCallsign(callsign);
|
||||
if (aircrafts.isEmpty()) return ifNotFound;
|
||||
return aircrafts.front();
|
||||
return this->findByCallsign(callsign).frontOrDefault(ifNotFound);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -62,13 +68,7 @@ namespace BlackMisc
|
||||
*/
|
||||
CUserList CAircraftList::getPilots() const
|
||||
{
|
||||
CUserList users;
|
||||
for (auto i = this->begin(); i != this->end(); ++i)
|
||||
{
|
||||
CAircraft aircraft = *i;
|
||||
if (aircraft.getPilot().isValid()) users.push_back(aircraft.getPilot());
|
||||
}
|
||||
return users;
|
||||
return this->findBy(Predicates::MemberValid(&CAircraft::getPilot)).transform(Predicates::MemberTransform(&CAircraft::getPilot));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user