mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
CIdentifierList utility function
getMachinesUnique() returns a list of identifiers reduced to maximum one per machine. If there is more than one per machine, it is undefined which one will be returned. refs #881
This commit is contained in:
committed by
Mathew Sutcliffe
parent
54b76d91ad
commit
2ab6e7f41e
@@ -26,6 +26,20 @@ namespace BlackMisc
|
|||||||
return containsBy([&other](const CIdentifier & id) { return ! other.contains(id); });
|
return containsBy([&other](const CIdentifier & id) { return ! other.contains(id); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CIdentifierList CIdentifierList::getMachinesUnique() const
|
||||||
|
{
|
||||||
|
CIdentifierList il;
|
||||||
|
for (const CIdentifier &identifier : *this)
|
||||||
|
{
|
||||||
|
bool contained = il.containsBy([ = ] (const CIdentifier &ident)
|
||||||
|
{
|
||||||
|
return identifier.isFromSameMachine(ident);
|
||||||
|
});
|
||||||
|
if (!contained) { il.push_back(identifier); }
|
||||||
|
}
|
||||||
|
return il;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList CIdentifierList::getMachineNames(bool unique, bool sort) const
|
QStringList CIdentifierList::getMachineNames(bool unique, bool sort) const
|
||||||
{
|
{
|
||||||
QStringList codes = this->transform(Predicates::MemberTransform(&CIdentifier::getMachineName));
|
QStringList codes = this->transform(Predicates::MemberTransform(&CIdentifier::getMachineName));
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ namespace BlackMisc
|
|||||||
//! This list contains an identifier which is not contained in other.
|
//! This list contains an identifier which is not contained in other.
|
||||||
bool containsAnyNotIn(const CIdentifierList &other) const;
|
bool containsAnyNotIn(const CIdentifierList &other) const;
|
||||||
|
|
||||||
|
//! Get a list of identifiers reduced to maximum one per machine.
|
||||||
|
//! If there is more than one per machine, it is undefined which one will be added.
|
||||||
|
CIdentifierList getMachinesUnique() const;
|
||||||
|
|
||||||
//! Get machine names
|
//! Get machine names
|
||||||
QStringList getMachineNames(bool unique = true, bool sort = true) const;
|
QStringList getMachineNames(bool unique = true, bool sort = true) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user