summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-01-23 13:31:53 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-01-23 13:31:53 +0100
commitf172e8f17c883dc54e1ac1b5924f2cb83fc343b6 (patch)
tree62cb007f01a813281c56999873e6b6308730a8aa /src
parentadc37703cd6897bc98c4f1655dca0946880ae134 (diff)
added equals operator to RangeSet and Range.
Diffstat (limited to 'src')
-rw-r--r--src/core/RangeSet.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/RangeSet.hpp b/src/core/RangeSet.hpp
index 2c138dc..b196dec 100644
--- a/src/core/RangeSet.hpp
+++ b/src/core/RangeSet.hpp
@@ -169,6 +169,16 @@ struct Range {
{
return Range(from, std::numeric_limits<T>::max());
}
+
+ friend bool operator==(const Range<T> &lhs, const Range<T> &rhs)
+ {
+ return lhs.start == rhs.start && lhs.end == rhs.end;
+ }
+
+ friend bool operator!=(const Range<T> &lhs, const Range<T> &rhs)
+ {
+ return !(lhs == rhs);
+ }
};
/**
@@ -341,6 +351,28 @@ public:
{
return this->ranges;
}
+
+ friend bool operator==(const RangeSet<T> &lhs, const RangeSet<T> &rhs)
+ {
+ if (lhs.ranges.size() != rhs.ranges.size()) {
+ return false;
+ }
+ auto leftIt = lhs.ranges.begin();
+ auto rightIt = rhs.ranges.begin();
+ while (leftIt != lhs.ranges.end()) {
+ if (*leftIt != *rightIt) {
+ return false;
+ }
+ leftIt++;
+ rightIt++;
+ }
+ return true;
+ }
+
+ friend bool operator!=(const RangeSet<T> &lhs, const RangeSet<T> &rhs)
+ {
+ return !(lhs == rhs);
+ }
};
}