sources/basics.h

branch
protocol5
changeset 165
718a8c4df538
parent 161
1c483b54ddcb
child 179
7fc34735178e
--- a/sources/basics.h	Fri Jul 22 18:03:50 2016 +0300
+++ b/sources/basics.h	Sat Jul 23 12:27:03 2016 +0300
@@ -78,12 +78,34 @@
 	return (a < b) ? a : b;
 }
 
+template<typename ContainerType>
+typename ContainerType::value_type min(const ContainerType& container)
+{
+	typename ContainerType::value_type result;
+
+	for (typename ContainerType::value_type element : container)
+		result = min(result, element);
+
+	return result;
+}
+
 template<typename T>
 T max (T a, T b)
 {
 	return (a > b) ? a : b;
 }
 
+template<typename ContainerType>
+typename ContainerType::value_type max(const ContainerType& container)
+{
+	typename ContainerType::value_type result;
+
+	for (typename ContainerType::value_type element : container)
+		result = max(result, element);
+
+	return result;
+}
+
 template<typename T>
 T clamp (T a, T b, T c)
 {

mercurial