1
0

Added a RemoveIf() function to cQueue

This commit is contained in:
Mattes D 2014-12-09 10:43:40 +01:00
parent d323c0ba76
commit 2ab8d2bd98

View File

@ -163,6 +163,29 @@ public:
return false;
}
/** Removes all items for which the predicate returns true. */
template <class Predicate>
void RemoveIf(Predicate a_Predicate)
{
cCSLock Lock(m_CS);
for (auto itr = m_Contents.begin(); itr != m_Contents.end();)
{
if (a_Predicate(*itr))
{
auto itr2 = itr;
++itr2;
m_Contents.erase(itr);
m_evtRemoved.Set();
itr = itr2;
}
else
{
++itr;
}
} // for itr - m_Contents[]
}
private:
/// The contents of the queue
QueueType m_Contents;