#include <Cmp.hh>
The main usage of the Cmp class is if several variables should be checked for ordering in which case several Cmp objects can be combined as follows: cmp(a1, a2) || cmp(b1, b2) || cmp(c1, c2)
where cmp is a global function for easy creation of Cmp objects.
Definition at line 202 of file Cmp.hh.
Public Member Functions | |
operator CmpState () const | |
Automatically convert to an enum. | |
operator int () const | |
Automatically convert to an integer. | |
template<typename U> | |
const Cmp< double > & | operator|| (const Cmp< U > &c) const |
If this state is equivalent, set this state to the state of c. | |
Standard constructors and destructors. | |
Cmp (const double p1, const double p2) | |
The default constructor. | |
template<typename U> | |
Cmp (const Cmp< U > &x) | |
The copy constructor. | |
~Cmp () | |
The destructor is not virtual since this is not intended to be a base class. | |
template<typename U> | |
const Cmp< double > & | operator= (const Cmp< U > &x) |
The assignment operator. | |
Private Member Functions | |
void | _compare () const |
Perform the actual comparison if necessary. | |
Private Attributes | |
CmpState | _value |
The state of this object. | |
double | _numA |
The objects to be compared. | |
double | _numB |
~Cmp | ( | ) | [inline] |
Cmp | ( | const double | p1, | |
const double | p2 | |||
) | [inline] |
The assignment operator.
Definition at line 223 of file Cmp.hh.
References Cmp::_value.
00223 { 00224 _value = x; 00225 return *this; 00226 }
operator CmpState | ( | ) | const [inline] |
Automatically convert to an enum.
Definition at line 232 of file Cmp.hh.
References Cmp::_compare(), and Cmp::_value.
operator int | ( | ) | const [inline] |
Automatically convert to an integer.
Definition at line 238 of file Cmp.hh.
References Cmp::_compare(), and Cmp::_value.
If this state is equivalent, set this state to the state of c.
Definition at line 245 of file Cmp.hh.
References Cmp::_compare(), Cmp::_value, and Rivet::EQUIVALENT.
00245 { 00246 _compare(); 00247 if (_value == EQUIVALENT) _value = c; 00248 return *this; 00249 }
void _compare | ( | ) | const [inline, private] |
Perform the actual comparison if necessary.
Definition at line 254 of file Cmp.hh.
References Cmp::_value, Rivet::EQUIVALENT, Rivet::fuzzyEquals(), Rivet::ORDERED, Rivet::UNDEFINED, and Rivet::UNORDERED.
00254 { 00255 if (_value == UNDEFINED) { 00256 if (fuzzyEquals(_numA,_numB)) _value = EQUIVALENT; 00257 else if (_numA < _numB) _value = ORDERED; 00258 else _value = UNORDERED; 00259 } 00260 }