Added difference operator overload for hashset.

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


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

Branch: refs/heads/master
Commit: 0cd87235ea75a946100e1b5aa0b110852ab4958f
Parents: 7b14bf7
Author: Zhitao Li <zhitaoli...@gmail.com>
Authored: Tue Mar 27 15:12:26 2018 -0700
Committer: Zhitao Li <zhitaoli...@gmail.com>
Committed: Mon Apr 9 10:46:02 2018 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/hashset.hpp | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0cd87235/3rdparty/stout/include/stout/hashset.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/hashset.hpp 
b/3rdparty/stout/include/stout/hashset.hpp
index 6af209c..2b86e5b 100644
--- a/3rdparty/stout/include/stout/hashset.hpp
+++ b/3rdparty/stout/include/stout/hashset.hpp
@@ -162,4 +162,30 @@ hashset<Elem, Hash, Equal>& operator|=(
   return left;
 }
 
+
+// Difference operator.
+template <typename Elem, typename Hash, typename Equal>
+hashset<Elem, Hash, Equal> operator-(
+    const hashset<Elem, Hash, Equal>& left,
+    const hashset<Elem, Hash, Equal>& right)
+{
+  hashset<Elem, Hash, Equal> result = left;
+  result -= right;
+  return result;
+}
+
+
+// Difference assignment operator.
+template <typename Elem, typename Hash, typename Equal>
+hashset<Elem, Hash, Equal>& operator-=(
+    hashset<Elem, Hash, Equal>& left,
+    const hashset<Elem, Hash, Equal>& right)
+{
+  foreach (const Elem& elem, right) {
+    left.erase(elem);
+  }
+
+  return left;
+}
+
 #endif // __STOUT_HASHSET_HPP__

Reply via email to