00001 #ifndef toast_algorithm_hpp_INCLUDED 00002 #define toast_algorithm_hpp_INCLUDED 00003 00010 namespace toast { 00011 00024 template <typename T> 00025 inline int compare(T const &a, T const &b) 00026 { 00027 if(a < b) return -1; 00028 if(b < a) return 1; 00029 return 0; 00030 } 00031 00041 template <typename T, typename Compare> 00042 inline int compare(T const &a, T const &b, Compare comp) 00043 { 00044 if(comp(a, b)) return -1; 00045 if(comp(b, a)) return 1; 00046 return 0; 00047 } 00048 00060 template <typename T> 00061 inline int (*get_compare())(T const &, T const &) 00062 { 00063 return &compare; 00064 } 00065 00077 template <typename T, typename Compare> 00078 inline int (*get_compare())(T const &, T const &, Compare) 00079 { 00080 return &compare; 00081 } 00082 00085 } 00086 00087 #endif // toast_algorithm_hpp_INCLUDED