]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/algorithm.h
Add implementations of find and find_if that take a container
[libs/core.git] / source / core / algorithm.h
diff --git a/source/core/algorithm.h b/source/core/algorithm.h
new file mode 100644 (file)
index 0000000..5d75763
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef MSP_CORE_ALGORITHM_H_
+#define MSP_CORE_ALGORITHM_H_
+
+#include <algorithm>
+
+namespace Msp {
+
+template<typename Container, typename T>
+typename Container::iterator find(Container &cont, const T &value)
+{
+       return std::find(cont.begin(), cont.end(), value);
+}
+
+template<typename Container, typename T>
+typename Container::const_iterator find(const Container &cont, const T &value)
+{
+       return std::find(cont.begin(), cont.end(), value);
+}
+
+template<typename Container, typename Predicate>
+typename Container::iterator find_if(Container &cont, Predicate pred)
+{
+       return std::find_if(cont.begin(), cont.end(), pred);
+}
+
+template<typename Container, typename Predicate>
+typename Container::const_iterator find_if(const Container &cont, Predicate pred)
+{
+       return std::find_if(cont.begin(), cont.end(), pred);
+}
+
+} // namespace Msp
+
+#endif