mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
refs #899, added replaceOrAddObjectsByCallsign utility function
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f71e717ec1
commit
297fef7c3c
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user