swift
Loading...
Searching...
No Matches
identifierlist.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <QStringList>
7
9
10SWIFT_DEFINE_SEQUENCE_MIXINS(swift::misc, CIdentifier, CIdentifierList)
11
12namespace swift::misc
13{
15
17 {
18 return containsBy([&other](const CIdentifier &id) { return !other.contains(id); });
19 }
20
22 {
24 for (const CIdentifier &identifier : *this)
25 {
26 bool contained =
27 il.containsBy([=](const CIdentifier &ident) { return identifier.hasSameMachineName(ident); });
28 if (!contained)
29 {
30 il.push_back(identifier);
31 }
32 }
33 return il;
34 }
35
37 {
39 if (sort)
40 {
41 codes.sort();
42 }
43 if (unique)
44 {
45 codes.removeDuplicates();
46 }
47 return codes;
48 }
49
51 {
52 if (this->size() < 2)
53 {
54 return 0;
55 }
57 for (const CIdentifier &identifier : *this)
58 {
59 if (il.contains(identifier)) continue;
60 il.push_back(identifier);
61 }
62 const int delta = this->size() - il.size();
63 if (delta == 0)
64 {
65 return 0;
66 }
67 *this = il;
68 return delta;
69 }
70} // namespace swift::misc
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition identifier.h:29
const QString & getMachineName() const
Machine name.
Definition identifier.h:103
bool hasSameMachineName(const CIdentifier &other) const
Check if the other identifier has the same machine name.
CSequence()=default
Default constructor.
CIdentifierList()=default
Default constructor.
QStringList getMachineNames(bool unique=true, bool sort=true) const
Get machine names.
int removeDuplicates()
Remove duplicates.
CIdentifierList getMachinesUnique() const
Get a list of identifiers reduced to maximum one per machine. If there is more than one per machine,...
bool containsAnyNotIn(const CIdentifierList &other) const
This list contains an identifier which is not contained in other.
bool contains(const T &object) const
Return true if there is an element equal to given object. Uses the most efficient implementation avai...
Definition range.h:109
void push_back(const T &value)
Appends an element at the end of the sequence.
Definition sequence.h:308
auto MemberTransform(T memberFunc)
Returns a function object that returns the value returned by one of it's argument member functions.
Definition predicates.h:54
Free functions in swift::misc.
qsizetype removeDuplicates()
void sort(Qt::CaseSensitivity cs)
#define SWIFT_DEFINE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template definition of mixins for a CSequence subclass.
Definition sequence.h:63