Add is_empty & set_empty to interval
This commit is contained in:
parent
93b99cf1ec
commit
8d06185694
2 changed files with 16 additions and 0 deletions
|
@ -107,6 +107,9 @@ public:
|
|||
*/
|
||||
bool contains(interval<T> & b) const;
|
||||
|
||||
bool is_empty() const;
|
||||
void set_empty();
|
||||
|
||||
/**
|
||||
\brief Return true is the interval contains only one value.
|
||||
*/
|
||||
|
|
|
@ -118,6 +118,19 @@ bool interval<T>::contains(interval<T> & b) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool interval<T>::is_empty() const {
|
||||
return m_lower == m_upper && m_lower_open && m_upper_open && !m_lower_inf && !m_upper_inf;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void interval<T>::set_empty() {
|
||||
numeric_traits<T>::reset(m_lower);
|
||||
numeric_traits<T>::reset(m_upper);
|
||||
m_lower_open = m_upper_open = true;
|
||||
m_lower_inf = m_upper_inf = true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool interval<T>::is_singleton() const {
|
||||
return !m_lower_inf && !m_upper_inf && !m_lower_open && !m_upper_open && m_lower == m_upper;
|
||||
|
|
Loading…
Reference in a new issue