summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/Queue.h
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-12-13 20:10:23 +0100
committerHowaner <franzi.moos@googlemail.com>2014-12-13 20:10:23 +0100
commita595a4a842123f10a4b27ae082794bad0250a307 (patch)
treeb0f50e06e6f7a55a8d5a18cfb37a53234f527236 /src/OSSupport/Queue.h
parentAdded cocoa pod. (diff)
parentMerge pull request #1663 from mc-server/APIDumpSize (diff)
downloadcuberite-a595a4a842123f10a4b27ae082794bad0250a307.tar
cuberite-a595a4a842123f10a4b27ae082794bad0250a307.tar.gz
cuberite-a595a4a842123f10a4b27ae082794bad0250a307.tar.bz2
cuberite-a595a4a842123f10a4b27ae082794bad0250a307.tar.lz
cuberite-a595a4a842123f10a4b27ae082794bad0250a307.tar.xz
cuberite-a595a4a842123f10a4b27ae082794bad0250a307.tar.zst
cuberite-a595a4a842123f10a4b27ae082794bad0250a307.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;