From 1793fa416371365f7435f1946cc556cc14613821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be> Date: Sun, 17 Jul 2011 19:02:09 +0200 Subject: Added PairFirstEquals. diff --git a/Swiften/Base/Algorithm.h b/Swiften/Base/Algorithm.h index b7459ed..4e68e70 100644 --- a/Swiften/Base/Algorithm.h +++ b/Swiften/Base/Algorithm.h @@ -77,6 +77,11 @@ namespace Swift { } } } + + template<typename C, typename P> + void eraseIfImpl(C& c, const P& p, VectorCategory) { + c.erase(std::remove_if(c.begin(), c.end(), p), c.end()); + } } template<typename C, typename V> @@ -115,6 +120,20 @@ namespace Swift { * Functors */ template<typename K, typename V> + class PairFirstEquals { + public: + PairFirstEquals(const K& value) : value(value) { + } + + bool operator()(const std::pair<K,V>& pair) const { + return pair.first == value; + } + + private: + K value; + }; + + template<typename K, typename V> class PairSecondEquals { public: PairSecondEquals(const V& value) : value(value) { -- cgit v0.10.2-6-g49f6