mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-03 16:25:54 +08:00
Add CSequence::removeIfIn(const CSequence &other)
Remove all elements if they are in other
This commit is contained in:
committed by
Mathew Sutcliffe
parent
a7b71d974b
commit
41e17aa0c7
@@ -388,6 +388,20 @@ namespace BlackMisc
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Remove all elements if they are in other
|
||||||
|
* \pre The sequence must be initialized.
|
||||||
|
* \return The number of elements removed.
|
||||||
|
*/
|
||||||
|
int removeIfIn(const CSequence &other)
|
||||||
|
{
|
||||||
|
auto newEnd = std::remove_if(begin(), end(), [&other](const T &v) { return other.contains(v); });
|
||||||
|
int count = std::distance(newEnd, end());
|
||||||
|
erase(newEnd, end());
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Replace elements matching the given element with a replacement.
|
* \brief Replace elements matching the given element with a replacement.
|
||||||
* \return The number of elements replaced.
|
* \return The number of elements replaced.
|
||||||
|
|||||||
Reference in New Issue
Block a user