Go to the documentation of this file.00001
00002 #ifndef vbl_sort_h_
00003 #define vbl_sort_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 int vbl_sort_double_ascending(double const&, double const&);
00020 int vbl_sort_double_descending(double const&, double const&);
00021
00022 int vbl_sort_int_ascending(int const&, int const&);
00023 int vbl_sort_int_descending(int const&, int const&);
00024
00025
00026
00027 template <class T>
00028 struct vbl_sort_helper
00029 {
00030 static int ascend(const void* a, const void* b) {
00031 T const& ta = *((T const*)a);
00032 T const& tb = *((T const*)b);
00033 return tb > ta ? -1 : tb == ta ? 0 : 1;
00034 }
00035 static int descend(const void* a, const void* b) {
00036 return - ascend(a,b);
00037 }
00038 };
00039
00040 #define VBL_SORT_INSTANTIATE(T) \
00041 template struct vbl_sort_helper<T >
00042
00043 #endif // vbl_sort_h_