diff --git a/src/interval/interval.h b/src/interval/interval.h index 8359dad43..5729bb5a2 100644 --- a/src/interval/interval.h +++ b/src/interval/interval.h @@ -107,6 +107,9 @@ public: */ bool contains(interval & b) const; + bool is_empty() const; + void set_empty(); + /** \brief Return true is the interval contains only one value. */ diff --git a/src/interval/interval_def.h b/src/interval/interval_def.h index b7ae43c56..28fcda1ba 100644 --- a/src/interval/interval_def.h +++ b/src/interval/interval_def.h @@ -118,6 +118,19 @@ bool interval::contains(interval & b) const { return true; } +template +bool interval::is_empty() const { + return m_lower == m_upper && m_lower_open && m_upper_open && !m_lower_inf && !m_upper_inf; +} + +template +void interval::set_empty() { + numeric_traits::reset(m_lower); + numeric_traits::reset(m_upper); + m_lower_open = m_upper_open = true; + m_lower_inf = m_upper_inf = true; +} + template bool interval::is_singleton() const { return !m_lower_inf && !m_upper_inf && !m_lower_open && !m_upper_open && m_lower == m_upper;