mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 14:38:04 -06: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:
@@ -54,16 +54,6 @@ namespace Algorithm
|
||||
it = (p(it.key(), it.value()) ? dict.erase(it) : ++it);
|
||||
}
|
||||
|
||||
// To be used with set types, such as QSet, std::set
|
||||
template <typename T, typename UnaryPredicate
|
||||
, typename std::enable_if_t<!HasMappedType<T>::value, int> = 0>
|
||||
void removeIf(T &set, UnaryPredicate &&p)
|
||||
{
|
||||
auto it = set.begin();
|
||||
while (it != set.end())
|
||||
it = (p(*it) ? set.erase(it) : ++it);
|
||||
}
|
||||
|
||||
template <typename List>
|
||||
List sorted(List list)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user