Some convenience functions ATC station

This commit is contained in:
Klaus Basan
2015-01-22 11:06:50 +01:00
parent 49a8dee67c
commit 9d14f8f42d
4 changed files with 69 additions and 5 deletions

View File

@@ -85,6 +85,17 @@ namespace BlackMisc
});
}
/*
* Find by suffix
*/
CAtcStationList CAtcStationList::findBySuffix(const QString &suffix) const
{
CAtcStationList r;
if (suffix.isEmpty()) { return r; }
r = this->findBy(&CAtcStation::getCallsignSuffix, suffix);
return r;
}
/*
* Distances to own plane
*/
@@ -104,6 +115,28 @@ namespace BlackMisc
return this->findBy(Predicates::MemberValid(&CAtcStation::getController)).transform(Predicates::MemberTransform(&CAtcStation::getController));
}
/*
* Suffixes with count
*/
QMap<QString, int> CAtcStationList::getSuffixes() const
{
QMap<QString, int> r;
for (const CAtcStation &station : (*this))
{
const QString s = station.getCallsignSuffix();
if (s.isEmpty()) { continue; }
if (r.contains(s))
{
r[s] = r[s] + 1;
}
else
{
r.insert(s, 1);
}
}
return r;
}
/*
* Merge with booking, both (online/booking will be updated)
*/