mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-06-28 17:33:14 -04:00
Use library provided erase_if()
`Algorithm::removeIf()` is still valuable as `QHash::removeIf()` predicate require an iterator or a `std::pair`, which both require more code to unpack the variable and therefore cumbersome to use. PR #19353.
This commit is contained in:
parent
9898901236
commit
e31c3376bd
6 changed files with 8 additions and 42 deletions
|
@ -91,34 +91,11 @@ private slots:
|
|||
}
|
||||
}
|
||||
|
||||
void testNonMappedTypeRemoveIf() const
|
||||
void testSorted() const
|
||||
{
|
||||
{
|
||||
QSet<char> data =
|
||||
{
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
'b',
|
||||
'd'
|
||||
};
|
||||
Algorithm::removeIf(data, [](const char value)
|
||||
{
|
||||
return (value == 'b');
|
||||
});
|
||||
QCOMPARE(data.size(), 3);
|
||||
QVERIFY(data.contains('a'));
|
||||
QVERIFY(data.contains('c'));
|
||||
QVERIFY(data.contains('d'));
|
||||
}
|
||||
{
|
||||
std::set<char> data;
|
||||
Algorithm::removeIf(data, [](const char value)
|
||||
{
|
||||
return (value == 'b');
|
||||
});
|
||||
QVERIFY(data.empty());
|
||||
}
|
||||
const QStringList list = {u"c"_s, u"b"_s, u"a"_s};
|
||||
const QStringList sortedList = {u"a"_s, u"b"_s, u"c"_s};
|
||||
QCOMPARE(Algorithm::sorted(list), sortedList);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue