diff --git a/src/spectrum/model/spectrum-value.cc b/src/spectrum/model/spectrum-value.cc index 80855328a..b388f8729 100644 --- a/src/spectrum/model/spectrum-value.cc +++ b/src/spectrum/model/spectrum-value.cc @@ -649,6 +649,94 @@ SpectrumValue:: operator= (double rhs) } +bool +SpectrumValue::operator== (const SpectrumValue& rhs) const +{ + Values::const_iterator it1 = this->m_values.begin (); + Values::const_iterator it2 = rhs.m_values.begin (); + + while ( it1 != this->m_values.end () && it2 != rhs.m_values.end () ) + { + if ( *it1 != *it2 ) + { + return false; + } + else + { + ++it1; + ++it2; + } + } + + if ( it1 == this->m_values.end () && it2 == rhs.m_values.end () ) + { + return true; + } + else + { + return false; + } +} + +bool +SpectrumValue::operator< (const SpectrumValue &rhs) const +{ + Values::const_iterator it1 = this->m_values.begin (); + Values::const_iterator it2 = rhs.m_values.begin (); + + while ( it1 != this->m_values.end () && it2 != rhs.m_values.end () ) + { + if ( *it1 >= *it2 ) + { + return false; + } + else + { + ++it1; + ++it2; + } + } + + if ( it1 == this->m_values.end () && it2 == rhs.m_values.end () ) + { + return true; + } + else + { + return false; + } +} + +bool +SpectrumValue::operator> (const SpectrumValue &rhs) const +{ + Values::const_iterator it1 = this->m_values.begin (); + Values::const_iterator it2 = rhs.m_values.begin (); + + while ( it1 != this->m_values.end () && it2 != rhs.m_values.end () ) + { + if ( *it1 <= *it2 ) + { + return false; + } + else + { + ++it1; + ++it2; + } + } + + if ( it1 == this->m_values.end () && it2 == rhs.m_values.end () ) + { + return true; + } + else + { + return false; + } +} + + SpectrumValue SpectrumValue:: operator<< (int n) const diff --git a/src/spectrum/model/spectrum-value.h b/src/spectrum/model/spectrum-value.h index 03aa12c7b..5c88e8246 100644 --- a/src/spectrum/model/spectrum-value.h +++ b/src/spectrum/model/spectrum-value.h @@ -400,6 +400,36 @@ public: + /** + * Compare each component, one by one + * + * @param rhs Right Hand Side of the operator + * + * @return True if this == rhs + * False if this != rhs + */ + bool operator== (const SpectrumValue& rhs) const; + + /** + * Compare each component, one by one + * + * @param rhs Right Hand Side of the operator + * + * @return True if this < rhs + * False if this >= rhs + */ + bool operator< (const SpectrumValue &rhs) const; + + /** + * Compare each component, one by one + * + * @param rhs Right Hand Side of the operator + * + * @return True if this > rhs + * False if this <= rhs + */ + bool operator> (const SpectrumValue &rhs) const; + /** * * @param x the operand