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 #ifndef MLN_DATA_COMPARE_HH
00028 # define MLN_DATA_COMPARE_HH
00029
00033
00034 # include <mln/core/concept/image.hh>
00035 # include <mln/fun/vv2b/eq.hh>
00036 # include <mln/fun/vv2b/le.hh>
00037 # include <mln/fun/vv2b/lt.hh>
00038 # include <mln/test/predicate.hh>
00039
00040
00041 namespace mln
00042 {
00043
00051
00052 template <typename L, typename R>
00053 bool operator == (const Image<L>& lhs, const Image<R>& rhs);
00054
00055
00063
00064 template <typename L, typename R>
00065 bool operator < (const Image<L>& lhs, const Image<R>& rhs);
00066
00067
00075
00076 template <typename L, typename R>
00077 bool operator <= (const Image<L>& lhs, const Image<R>& rhs);
00078
00079
00080
00081 # ifndef MLN_INCLUDE_ONLY
00082
00083
00084 template <typename L, typename R>
00085 inline
00086 bool operator == (const Image<L>& lhs_, const Image<R>& rhs_)
00087 {
00088 trace::entering("data::compare (==)");
00089
00090 const L& lhs = exact(lhs_);
00091 const R& rhs = exact(rhs_);
00092
00093 mln_precondition(lhs.is_valid());
00094 mln_precondition(rhs.is_valid());
00095 mln_precondition(lhs.domain() == rhs.domain());
00096
00097 typedef fun::vv2b::eq<mln_value(L), mln_value(R)> F;
00098 bool res = test::predicate(lhs, rhs, F());
00099
00100 trace::exiting("data::compare (==)");
00101 return res;
00102 }
00103
00104
00105 template <typename L, typename R>
00106 inline
00107 bool operator < (const Image<L>& lhs_, const Image<R>& rhs_)
00108 {
00109 trace::entering("data::compare (<)");
00110
00111 const L& lhs = exact(lhs_);
00112 const R& rhs = exact(rhs_);
00113
00114 mln_precondition(lhs.domain() == rhs.domain());
00115
00116 typedef fun::vv2b::lt<mln_value(L), mln_value(R)> F;
00117 bool res = test::predicate(lhs_, rhs_, F());
00118
00119 trace::exiting("data::compare (<)");
00120 return res;
00121 }
00122
00123
00124 template <typename L, typename R>
00125 inline
00126 bool operator <= (const Image<L>& lhs_, const Image<R>& rhs_)
00127 {
00128 trace::entering("data::compare (<=)");
00129
00130 const L& lhs = exact(lhs_);
00131 const R& rhs = exact(rhs_);
00132
00133 mln_precondition(lhs.domain() == rhs.domain());
00134
00135 typedef fun::vv2b::le<mln_value(L), mln_value(R)> F;
00136 bool res = test::predicate(lhs_, rhs_, F());
00137
00138 trace::exiting("data::compare (<=)");
00139 return res;
00140 }
00141
00142 # endif // ! MLN_INCLUDE_ONLY
00143
00144 }
00145
00146
00147 #endif // ! MLN_DATA_COMPARE_HH