vtf-logo

coordinateCompare.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__ads_coordinateCompare_h__)
00009 #define __ads_coordinateCompare_h__
00010 
00011 // If we are debugging the whole ads package.
00012 #if defined(DEBUG_ads) && !defined(DEBUG_coordinateCompare)
00013 #define DEBUG_coordinateCompare
00014 #endif
00015 
00016 #include "../defs.h"
00017 
00018 #include <functional>
00019 
00020 #include <cassert>
00021 
00022 BEGIN_NAMESPACE_ADS
00023   
00024 //-----------------------------------------------------------------------------
00026 // @{
00027 
00029 
00032 template<typename Point>
00033 class LessThanCompareCoordinate :
00034   public std::binary_function<Point, Point, bool> {
00035 private:
00036 
00037   typedef std::binary_function<Point, Point, bool> Base;
00038 
00039   int _n;
00040 
00041 public:
00042 
00044   typedef typename Base::first_argument_type first_argument_type;
00046   typedef typename Base::second_argument_type second_argument_type;
00048   typedef typename Base::result_type result_type;
00049   
00051   LessThanCompareCoordinate(const int n = -1) :
00052     _n(n)
00053   {}
00054   
00055   // We use the default copy constructor, assignment operator, and destructor.
00056 
00058   void
00059   setCoordinate(const int n) {
00060     _n = n;
00061   }
00062 
00064   bool 
00065   operator()(const first_argument_type& x, const second_argument_type& y) 
00066     const {
00067 #ifdef DEBUG_coordinateCompare
00068     assert(_n >= 0);
00069 #endif
00070     return x[_n] < y[_n];
00071   }
00072 };
00073 
00074 
00076 
00079 template<typename Point>
00080 LessThanCompareCoordinate<Point>
00081 constructLessThanCompareCoordinate(const int n = -1) {
00082   return LessThanCompareCoordinate<Point>(n);
00083 }
00084 
00085 
00086 // @}
00087 
00088 END_NAMESPACE_ADS
00089 
00090 #endif

Generated on Fri Aug 24 12:55:24 2007 for Algorithms and Data Structures Package by  doxygen 1.4.7