Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __ADJACENT_PREDICATE__
00031 #define __ADJACENT_PREDICATE__
00032
00033 #include <functional>
00034 #include <utility>
00035 #include "DisplayPair.hxx"
00036
00037 template < typename T >
00038 struct AdjacentPredicate : public std::binary_function < T, T, bool >
00039 {
00040 T _value;
00041 AdjacentPredicate(const T& value):_value(value){}
00042 bool operator()(const T &v1, const T& v2) const {
00043 return (v1 <= _value ) && (_value < v2) ;
00044 }
00045 };
00046
00047
00048 template <typename T1, typename T2, typename T3>
00049 struct AdjacentPredicate< std::pair<const std::pair<T1,T2>, T3 > > :
00050 public std::binary_function < std::pair<const std::pair<T1,T2>, T3 >,
00051 std::pair<const std::pair<T1,T2>, T3 >, bool >
00052 {
00053 std::pair<T1,T2> _value;
00054 AdjacentPredicate(const std::pair<T1,T2> & value):_value(value){
00055 std::cout << "1-Initializing with value " << _value << std::endl;
00056 }
00057 bool operator()( const std::pair<const std::pair<T1,T2>, T3 > & v1,
00058 const std::pair<const std::pair<T1,T2>, T3 > v2) const {
00059 std::cout << "1-> :" << v1 << "," << v2 << " " << std::endl;
00060 return (v1.first <= _value ) && (_value < v2.first) ;
00061 }
00062 };
00063
00064 template <typename T1, typename T2>
00065 struct AdjacentPredicate< std::pair<T1,T2> > : public std::binary_function < std::pair<T1,T2>, std::pair<T1,T2>, bool >
00066 {
00067 T1 _value;
00068 AdjacentPredicate(const T1 & value):_value(value){
00069 std::cout << "2-Initializing with value " << _value << std::endl;
00070 }
00071 bool operator()( const std::pair<T1,T2> & v1, const std::pair<T1,T2>& v2) const {
00072 std::cout << "2-> :" << &(v1.first) << "," << &(v2.first) << " " << std::endl;
00073 return (v1.first <= _value ) && (_value < v2.first) ;
00074 }
00075 };
00076
00077 #endif