mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Ref T218, sequence replaceOrAdd overloads
This commit is contained in:
@@ -798,7 +798,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CProcessInfo currentProcess = CProcessInfo::currentProcess();
|
CProcessInfo currentProcess = CProcessInfo::currentProcess();
|
||||||
Q_ASSERT(currentProcess.exists());
|
Q_ASSERT(currentProcess.exists());
|
||||||
apps.replaceOrAdd(currentProcess, currentProcess);
|
apps.replaceOrAdd(currentProcess);
|
||||||
json.insert("apps", apps.toJson());
|
json.insert("apps", apps.toJson());
|
||||||
json.insert("uuid", uuid.toString());
|
json.insert("uuid", uuid.toString());
|
||||||
if (!(file.seek(0) && file.resize(0) && file.write(QJsonDocument(json).toJson()) && file.checkedClose()))
|
if (!(file.seek(0) && file.resize(0) && file.write(QJsonDocument(json).toJson()) && file.checkedClose()))
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace BlackMisc
|
|||||||
CUrlList withoutDuplicates;
|
CUrlList withoutDuplicates;
|
||||||
for (const CUrl &url : (*this))
|
for (const CUrl &url : (*this))
|
||||||
{
|
{
|
||||||
withoutDuplicates.replaceOrAdd(url, url);
|
withoutDuplicates.replaceOrAdd(url);
|
||||||
}
|
}
|
||||||
return withoutDuplicates;
|
return withoutDuplicates;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Generic sequential container with value semantics.
|
* Generic sequential container with value semantics.
|
||||||
* \tparam T the type of elements contained.
|
* \tparam T the type of elements contained.
|
||||||
@@ -351,6 +350,21 @@ namespace BlackMisc
|
|||||||
else { push_back(replacement); }
|
else { push_back(replacement); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Replace elements matching the given element. If there is no match, push the new element on the end.
|
||||||
|
void replaceOrAdd(const T &replacement)
|
||||||
|
{
|
||||||
|
this->replaceOrAdd(replacement, replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Replace or add given elements
|
||||||
|
void replaceOrAdd(const CSequence<T> &replacements)
|
||||||
|
{
|
||||||
|
for (const T &replacement : replacements)
|
||||||
|
{
|
||||||
|
this->replaceOrAdd(replacement, replacement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! Replace elements matching a particular key/value pair. If there is no match, push the new element on the end.
|
//! Replace elements matching a particular key/value pair. If there is no match, push the new element on the end.
|
||||||
//! \param key1 A pointer to a member function of T.
|
//! \param key1 A pointer to a member function of T.
|
||||||
//! \param value1 Will be compared to the return value of key1.
|
//! \param value1 Will be compared to the return value of key1.
|
||||||
@@ -505,7 +519,6 @@ namespace BlackMisc
|
|||||||
private:
|
private:
|
||||||
QVector<T> m_impl;
|
QVector<T> m_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace BlackMisc
|
} //namespace BlackMisc
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<int>)
|
Q_DECLARE_METATYPE(BlackMisc::CSequence<int>)
|
||||||
|
|||||||
Reference in New Issue
Block a user