summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/Queue.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-12-11 17:06:18 +0100
committerMattes D <github@xoft.cz>2014-12-11 17:06:18 +0100
commit781b3303a5aeb1ac572d83452186ed3777040487 (patch)
tree43cec18a07f201e8c94e9ac318f4635b0d4053bb /src/OSSupport/Queue.h
parentCosmetic touchups. (diff)
parentAdded a cWorld:PrepareChunk function. (diff)
downloadcuberite-781b3303a5aeb1ac572d83452186ed3777040487.tar
cuberite-781b3303a5aeb1ac572d83452186ed3777040487.tar.gz
cuberite-781b3303a5aeb1ac572d83452186ed3777040487.tar.bz2
cuberite-781b3303a5aeb1ac572d83452186ed3777040487.tar.lz
cuberite-781b3303a5aeb1ac572d83452186ed3777040487.tar.xz
cuberite-781b3303a5aeb1ac572d83452186ed3777040487.tar.zst
cuberite-781b3303a5aeb1ac572d83452186ed3777040487.zip
Diffstat (limited to 'src/OSSupport/Queue.h')
-rw-r--r--src/OSSupport/Queue.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h
index 8d096fe29..82f221453 100644
--- a/src/OSSupport/Queue.h
+++ b/src/OSSupport/Queue.h
@@ -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;