refs #899, added replaceOrAddObjectsByCallsign utility function

This commit is contained in:
Klaus Basan
2017-03-06 02:30:52 +01:00
committed by Mathew Sutcliffe
parent f71e717ec1
commit 297fef7c3c
2 changed files with 20 additions and 0 deletions

View File

@@ -173,6 +173,24 @@ namespace BlackMisc
return result;
}
template<class OBJ, class CONTAINER>
int ICallsignObjectList<OBJ, CONTAINER>::replaceOrAddObjectsByCallsign(const CONTAINER &others)
{
if (others.isEmpty()) { return 0; }
int c = 0;
CONTAINER copy(this->container());
for (const OBJ &obj : others)
{
const CCallsign cs(obj.getCallsign());
if (cs.isEmpty()) continue;
copy.removeByCallsign(cs);
copy.push_back(obj);
c++;
}
*this = copy;
return c;
}
template <class OBJ, class CONTAINER>
void ICallsignObjectList<OBJ, CONTAINER>::sortByCallsign()
{

View File

@@ -87,6 +87,8 @@ namespace BlackMisc
//! Split into 0..n containers as per callsign
QHash<BlackMisc::Aviation::CCallsign, CONTAINER> splitPerCallsign() const;
//! Replace or add objects by callsign
int replaceOrAddObjectsByCallsign(const CONTAINER &others);
//! Incremental update or add object
int incrementalUpdateOrAdd(const OBJ &objectBeforeChanged, const BlackMisc::CPropertyIndexVariantMap &changedValues);