lestes::std::pair_comparator< T, ComparatorFirst, ComparatorSecond > Class Template Reference

#include <pair_comparator.hh>

List of all members.

Public Types

typedef ComparatorFirst< typename
T::pointee_type::first_type > 
comparator_first
typedef ComparatorSecond<
typename T::pointee_type::second_type > 
comparator_second

Public Member Functions

bool operator() (const T &a, const T &b) const
 compares lexicographically a pair


Detailed Description

template<typename T, template< typename U > class ComparatorFirst = ::std::less, template< typename U > class ComparatorSecond = ComparatorFirst>
class lestes::std::pair_comparator< T, ComparatorFirst, ComparatorSecond >

Definition at line 56 of file pair_comparator.hh.


Member Typedef Documentation

template<typename T, template< typename U > class ComparatorFirst = ::std::less, template< typename U > class ComparatorSecond = ComparatorFirst>
typedef ComparatorFirst< typename T::pointee_type::first_type > lestes::std::pair_comparator< T, ComparatorFirst, ComparatorSecond >::comparator_first

Definition at line 63 of file pair_comparator.hh.

template<typename T, template< typename U > class ComparatorFirst = ::std::less, template< typename U > class ComparatorSecond = ComparatorFirst>
typedef ComparatorSecond< typename T::pointee_type::second_type > lestes::std::pair_comparator< T, ComparatorFirst, ComparatorSecond >::comparator_second

Definition at line 64 of file pair_comparator.hh.


Member Function Documentation

template<typename T, template< typename U > class ComparatorFirst = ::std::less, template< typename U > class ComparatorSecond = ComparatorFirst>
bool lestes::std::pair_comparator< T, ComparatorFirst, ComparatorSecond >::operator() ( const T &  a,
const T &  b 
) const [inline]

compares lexicographically a pair

The inner workings determine the ordering by examining first the first part of the pair. If the first pair's first element is strictly less (where less is the relation of ComparatorFirst) than the second's, the whole first pair is less (the relation imposed by this comparator) than the second. If however the second's first is less than the first's, the first pair is not less than second. In the remaining case, i.e. neither first's first nor second's first is less than the other, the relation on the pair is determined solely by ComparatorSecond on the seconds of both pairs.

Definition at line 81 of file pair_comparator.hh.

00082          {
00083                  comparator_first ftc;
00084                  bool ab = ftc(a->first, b->first);
00085                  if (ab)
00086                          return true;
00087                  bool ba = ftc(b->first, a->first);
00088                  if (ba)
00089                          return false;
00090                  comparator_second stc;
00091                  return stc(a->second, b->second);
00092          }


The documentation for this class was generated from the following file:
Generated on Mon Feb 12 18:26:00 2007 for lestes by doxygen 1.5.1-20070107