#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 25 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< T > & | operator|| (const Cmp< U > &c) const |
If this state is equivalent, set this state to the state of c. | |
Standard constructors etc. | |
Cmp (const T &t1, const T &t2) | |
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< T > & | 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. | |
pair< const T *, const T * > | _objects |
The objects to be compared. |
Cmp | ( | const T & | t1, | |
const T & | t2 | |||
) | [inline] |
~Cmp | ( | ) | [inline] |
The assignment operator.
Definition at line 44 of file Cmp.hh.
References Cmp::_value.
00044 { 00045 _value = x; 00046 return *this; 00047 }
operator CmpState | ( | ) | const [inline] |
Automatically convert to an enum.
Definition at line 53 of file Cmp.hh.
References Cmp::_compare(), and Cmp::_value.
operator int | ( | ) | const [inline] |
Automatically convert to an integer.
Definition at line 59 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 66 of file Cmp.hh.
References Cmp::_compare(), Cmp::_value, and Rivet::EQUIVALENT.
00066 { 00067 _compare(); 00068 if (_value == EQUIVALENT) _value = c; 00069 return *this; 00070 }
void _compare | ( | ) | const [inline, private] |
Perform the actual comparison if necessary.
Definition at line 75 of file Cmp.hh.
References Cmp::_objects, Cmp::_value, Rivet::EQUIVALENT, Rivet::ORDERED, Rivet::UNDEFINED, and Rivet::UNORDERED.
Referenced by Cmp< double >::operator CmpState(), Cmp< Projection >::operator CmpState(), Cmp::operator CmpState(), Cmp< double >::operator int(), Cmp< Projection >::operator int(), Cmp::operator int(), Cmp< double >::operator||(), Cmp< Projection >::operator||(), and Cmp::operator||().
00075 { 00076 if (_value == UNDEFINED) { 00077 less<T> l; 00078 if ( l(*_objects.first, *_objects.second) ) _value = ORDERED; 00079 else if ( l(*_objects.second, *_objects.first) ) _value = UNORDERED; 00080 else _value = EQUIVALENT; 00081 } 00082 }
The state of this object.
Definition at line 85 of file Cmp.hh.
Referenced by Cmp< double >::_compare(), Cmp< Projection >::_compare(), Cmp::_compare(), Cmp< double >::operator CmpState(), Cmp< Projection >::operator CmpState(), Cmp::operator CmpState(), Cmp< double >::operator int(), Cmp< Projection >::operator int(), Cmp::operator int(), Cmp< double >::operator=(), Cmp< Projection >::operator=(), Cmp::operator=(), Cmp< double >::operator||(), Cmp< Projection >::operator||(), and Cmp::operator||().
pair<const T*, const T*> _objects [private] |
The objects to be compared.
Definition at line 88 of file Cmp.hh.
Referenced by Cmp< Projection >::_compare(), and Cmp::_compare().