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 2014/06/11 19:08:29 UTC

git commit: Added infix operator for IntervalSet.

Repository: mesos
Updated Branches:
  refs/heads/master 2b6a60995 -> 5d9d3d784


Added infix operator for IntervalSet.

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


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

Branch: refs/heads/master
Commit: 5d9d3d78412fe8faddf2c9197309c2aca588b0ba
Parents: 2b6a609
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Jun 10 13:06:59 2014 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 11 10:08:12 2014 -0700

----------------------------------------------------------------------
 .../3rdparty/stout/include/stout/interval.hpp     | 18 ++++++++++++++++++
 .../3rdparty/stout/tests/interval_tests.cpp       | 16 ++++++++++++++++
 2 files changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5d9d3d78/3rdparty/libprocess/3rdparty/stout/include/stout/interval.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/interval.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/interval.hpp
index a470307..89e77bf 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/interval.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/interval.hpp
@@ -334,6 +334,24 @@ bool Interval<T>::intersects(const IntervalSet<T>& set) const
 }
 
 
+template <typename T, typename X>
+IntervalSet<T> operator + (const IntervalSet<T>& set, const X& x)
+{
+  IntervalSet<T> result(set);
+  result += x;
+  return result;
+}
+
+
+template <typename T, typename X>
+IntervalSet<T> operator - (const IntervalSet<T>& set, const X& x)
+{
+  IntervalSet<T> result(set);
+  result -= x;
+  return result;
+}
+
+
 // Defines type traits for the custom Interval above. These type
 // traits are required by the boost interval set.
 namespace boost {

http://git-wip-us.apache.org/repos/asf/mesos/blob/5d9d3d78/3rdparty/libprocess/3rdparty/stout/tests/interval_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/interval_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/interval_tests.cpp
index a80543b..1fa8fc1 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/interval_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/interval_tests.cpp
@@ -386,3 +386,19 @@ TEST(IntervalTest, Stream)
   set += (Bound<int>::closed(7), Bound<int>::closed(9));
   EXPECT_EQ("{[5,6)[7,10)}", stringify(set));
 }
+
+
+TEST(IntervalTest, InfixOperator)
+{
+  IntervalSet<int> set1(Bound<int>::closed(0), Bound<int>::closed(1));
+  IntervalSet<int> set2(Bound<int>::closed(2), Bound<int>::open(3));
+  IntervalSet<int> set3(Bound<int>::closed(0), Bound<int>::closed(2));
+
+  EXPECT_EQ(set3, set1 + set2);
+  EXPECT_EQ(set3, set1 + (Bound<int>::closed(2), Bound<int>::open(3)));
+  EXPECT_EQ(set3, set1 + 2);
+
+  EXPECT_EQ(set1, set3 - set2);
+  EXPECT_EQ(set2, set3 - (Bound<int>::closed(0), Bound<int>::closed(1)));
+  EXPECT_EQ(set1, set3 - 2);
+}