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 #ifndef MLN_UTIL_ORD_HH
00027 # define MLN_UTIL_ORD_HH
00028 
00032 
00033 
00034 # include <mln/core/concept/object.hh>
00035 # include <mln/trait/op/ord.hh>
00036 
00037 
00038 
00039 namespace mln
00040 {
00041 
00042   namespace util
00043   {
00044 
00047     template <typename T>
00048     struct ord
00049     {
00050       bool operator()(const T& lhs, const T& rhs) const;
00051     };
00052 
00053 
00054 
00056     template <typename T>
00057     bool ord_strict(const T& lhs, const T& rhs);
00058 
00059 
00061     template <typename T>
00062     bool ord_weak(const T& lhs, const T& rhs);
00063 
00064 
00065     template <typename T1, typename T2>
00066     bool ord_lexi_strict(const T1& lhs_1, const T2& lhs_2,
00067                          const T1& rhs_1, const T2& rhs_2);
00068 
00069 
00070 
00071 # ifndef MLN_INCLUDE_ONLY
00072 
00073     
00074 
00075     template <typename T>
00076     inline
00077     bool
00078     ord<T>::operator()(const T& lhs, const T& rhs) const
00079     {
00080       typedef typename mln::trait::op::ord<T>::ret F;
00081       static const F f_ord = F();
00082       return f_ord.strict(lhs, rhs);
00083     }
00084 
00085     
00086 
00087     template <typename T>
00088     inline
00089     bool
00090     ord_strict(const T& lhs, const T& rhs)
00091     {
00092       typedef typename mln::trait::op::ord<T>::ret F;
00093       static const F f_ord = F();
00094       return f_ord.strict(lhs, rhs);
00095     }
00096 
00097     
00098 
00099     template <typename T>
00100     inline
00101     bool ord_weak(const T& lhs, const T& rhs)
00102     {
00103       typedef typename mln::trait::op::ord<T>::ret F;
00104       static const F f_ord = F();
00105       return f_ord.weak(lhs, rhs);
00106     }
00107 
00108     
00109 
00110     template <typename T1, typename T2>
00111     inline
00112     bool
00113     ord_lexi_strict(const T1& lhs_1, const T2& lhs_2,
00114                     const T1& rhs_1, const T2& rhs_2)
00115     {
00116       return
00117         util::ord_strict(lhs_1, rhs_1) ||
00118         (lhs_1 == rhs_1 && util::ord_strict(lhs_2, rhs_2));
00119     }
00120 
00121 # endif // ! MLN_INCLUDE_ONLY
00122 
00123   } 
00124 
00125 } 
00126 
00127 
00128 #endif // ! MLN_UTIL_ORD_HH