mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Allow to split callsign based list + samples
This commit is contained in:
@@ -186,6 +186,18 @@ namespace BlackMiscTest
|
||||
}
|
||||
out << "Reads by callsigns: " << timer.elapsed() << "ms" << endl;
|
||||
|
||||
timer.start();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
QMap<CCallsign, CAircraftSituationList> splitList = situations.splitPerCallsign();
|
||||
Q_ASSERT(splitList.size() == numberOfCallsigns);
|
||||
for (const CAircraftSituationList &slcs : splitList.values())
|
||||
{
|
||||
Q_ASSERT(slcs.size() == numberOfTimes);
|
||||
}
|
||||
}
|
||||
out << "Reads by callsigns split: " << timer.elapsed() << "ms" << endl;
|
||||
|
||||
timer.start();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@@ -204,9 +216,10 @@ namespace BlackMiscTest
|
||||
{
|
||||
CCallsign callsign("CS" + QString::number(cs));
|
||||
CAircraftSituationList r = situations.findByCallsign(callsign).findBefore(baseTimeEpoch + 1 + (10 * t));
|
||||
Q_UNUSED(r);
|
||||
}
|
||||
}
|
||||
out << "Reads by callsign / times: " << timer.elapsed() << "ms" << endl;
|
||||
out << "Reads by callsigns / times: " << timer.elapsed() << "ms" << endl;
|
||||
|
||||
timer.start();
|
||||
for (int t = 0; t < numberOfTimes; t++)
|
||||
@@ -215,9 +228,23 @@ namespace BlackMiscTest
|
||||
{
|
||||
CCallsign callsign("CS" + QString::number(cs));
|
||||
CAircraftSituationList r = situations.findBefore(baseTimeEpoch + 1 + (10 * t)).findByCallsign(callsign);
|
||||
Q_UNUSED(r);
|
||||
}
|
||||
}
|
||||
out << "Reads by times / callsign: " << timer.elapsed() << "ms" << endl;
|
||||
out << "Reads by times / callsigns: " << timer.elapsed() << "ms" << endl;
|
||||
|
||||
timer.start();
|
||||
for (int t = 0; t < numberOfTimes; t++)
|
||||
{
|
||||
QMap<CCallsign, CAircraftSituationList> splitList = situations.splitPerCallsign();
|
||||
Q_ASSERT(splitList.size() == numberOfCallsigns);
|
||||
for (const CAircraftSituationList &slcs : splitList.values())
|
||||
{
|
||||
CAircraftSituationList r = slcs.findBefore(baseTimeEpoch + 1 + (10 * t));
|
||||
Q_UNUSED(r);
|
||||
}
|
||||
}
|
||||
out << "Split reads by callsigns / times: " << timer.elapsed() << "ms" << endl;
|
||||
|
||||
situations.changeImpl<QVector<CAircraftSituation> >();
|
||||
out << "Changed to QVector" << endl;
|
||||
|
||||
@@ -99,6 +99,40 @@ namespace BlackMisc
|
||||
return r;
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
QMap<CCallsign, CONTAINER> ICallsignObjectList<OBJ, CONTAINER>::splitPerCallsign() const
|
||||
{
|
||||
CONTAINER copyContainer(getContainer());
|
||||
copyContainer.sortByCallsign();
|
||||
QMap<CCallsign, CONTAINER> result;
|
||||
CCallsign cs;
|
||||
for (const OBJ &csObj : copyContainer)
|
||||
{
|
||||
if (csObj.getCallsign().isEmpty())
|
||||
{
|
||||
Q_ASSERT(false); // there should be no empty callsigns
|
||||
continue;
|
||||
}
|
||||
if (cs != csObj.getCallsign())
|
||||
{
|
||||
cs = csObj.getCallsign();
|
||||
CONTAINER perCallsign({ csObj });
|
||||
result.insert(cs, perCallsign);
|
||||
}
|
||||
else
|
||||
{
|
||||
result[cs].push_back(csObj);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
void ICallsignObjectList<OBJ, CONTAINER>::sortByCallsign()
|
||||
{
|
||||
getContainer().sortBy(&OBJ::getCallsign);
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
int ICallsignObjectList<OBJ, CONTAINER>::incrementalUpdateOrAdd(const OBJ &objectBeforeChanges, const CPropertyIndexVariantMap &changedValues)
|
||||
{
|
||||
|
||||
@@ -57,6 +57,12 @@ namespace BlackMisc
|
||||
//! All suffixes with their respective count
|
||||
QMap<QString, int> getSuffixes() const;
|
||||
|
||||
//! Split into 0..n containers as per callsign
|
||||
QMap<BlackMisc::Aviation::CCallsign, CONTAINER> splitPerCallsign() const;
|
||||
|
||||
//! Sort by callsign
|
||||
void sortByCallsign();
|
||||
|
||||
//! Incremental update or add object
|
||||
int incrementalUpdateOrAdd(const OBJ &objectBeforeChanged, const BlackMisc::CPropertyIndexVariantMap &changedValues);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user