Added a RemoveIf() function to cQueue
parent
d323c0ba76
commit
2ab8d2bd98
|
@ -163,6 +163,29 @@ public:
|
||||||
return false;
|
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:
|
private:
|
||||||
/// The contents of the queue
|
/// The contents of the queue
|
||||||
QueueType m_Contents;
|
QueueType m_Contents;
|
||||||
|
|
Loading…
Reference in New Issue