diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-01-24 14:39:52 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-01-24 14:39:52 +0100 |
commit | a8af099733b573d69436add61ba633cded420c00 (patch) | |
tree | 5272386794157f50393b4372b9469d719c452951 /src/core/RangeSet.hpp | |
parent | 67d36e699a2852ce471c4d1b8dab5992d6c01a98 (diff) |
added some functions on the state of a Range (isPrimitive, isCOmpact, isOpenLow, isOpenHigh)
Diffstat (limited to 'src/core/RangeSet.hpp')
-rw-r--r-- | src/core/RangeSet.hpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/core/RangeSet.hpp b/src/core/RangeSet.hpp index b196dec..fc0070f 100644 --- a/src/core/RangeSet.hpp +++ b/src/core/RangeSet.hpp @@ -128,7 +128,7 @@ struct Range { /** * Calculates the union of the two ranges -- note that this operation is - * only valid if the ranges overlapp. Use the RangeSet class if you cannot + * only valid if the ranges overlap. Use the RangeSet class if you cannot * guarantee that. */ Range<T> merge(const Range<T> &r) const @@ -137,6 +137,44 @@ struct Range { } /** + * Returns true if and only if this Range only accepts a single element. + * + * @return true if and only if this Range only accepts a single element. + */ + bool isPrimitive() const { return start == end; } + /** + * Returns true if and only if this Range [a,b] meets the criteria: + * * a > lower limit of the type range (a > negative infinity) + * * a < b + * * b < upper limit of the type range (b < infinity) + * + * @return true if and only if this Range is compact as defined above. + */ + bool isCompact() const + { + return start > std::numeric_limits<T>::min() && start < end && + end < std::numeric_limits<T>::max(); + } + + /** + * Returns true if and only if the lower limit of this Range is equal to the + * type minimum (negative infinity). + * + * @return true if and only if this Range is open at the lower end in the + * sense defined above. + */ + bool isOpenLow() const { return start == std::numeric_limits<T>::min(); } + + /** + * Returns true if and only if the upper limit of this Range is equal to the + * type maximum (positive infinity). + * + * @return true if and only if this Range is open at the upper end in the + * sense defined above. + */ + bool isOpenHigh() const { return end == std::numeric_limits<T>::max(); } + + /** * Returns a range that represents the spans the complete set defined by the * given type T. */ |