You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2015/03/19 23:36:33 UTC

mesos git commit: Added operator+= and operator+ for hashmap.

Repository: mesos
Updated Branches:
  refs/heads/master e90b77d27 -> 9f8ab2866


Added operator+= and operator+ for hashmap<SlaveID, Resources>.

Review: https://reviews.apache.org/r/31664


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9f8ab286
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9f8ab286
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9f8ab286

Branch: refs/heads/master
Commit: 9f8ab28667ace1263cd49ff1a569edc3524b7b8b
Parents: e90b77d
Author: Michael Park <mc...@gmail.com>
Authored: Thu Mar 19 15:35:37 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Mar 19 15:35:37 2015 -0700

----------------------------------------------------------------------
 include/mesos/resources.hpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9f8ab286/include/mesos/resources.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/resources.hpp b/include/mesos/resources.hpp
index dd578ca..56affd4 100644
--- a/include/mesos/resources.hpp
+++ b/include/mesos/resources.hpp
@@ -24,6 +24,7 @@
 #include <vector>
 
 #include <mesos/mesos.hpp>
+#include <mesos/type_utils.hpp>
 #include <mesos/values.hpp>
 
 #include <stout/bytes.hpp>
@@ -321,6 +322,29 @@ inline bool operator == (
   return Resources(left) == right;
 }
 
+
+template <typename Key>
+hashmap<Key, Resources>& operator += (
+    hashmap<Key, Resources>& left,
+    const hashmap<Key, Resources>& right)
+{
+  foreachpair (const Key& key, const Resources& resources, right) {
+    left[key] += resources;
+  }
+  return left;
+}
+
+
+template <typename Key>
+hashmap<Key, Resources> operator + (
+    const hashmap<Key, Resources>& left,
+    const hashmap<Key, Resources>& right)
+{
+  hashmap<Key, Resources> result = left;
+  result += right;
+  return result;
+}
+
 } // namespace mesos {
 
 #endif // __RESOURCES_HPP__