vbl_sort.cxx
Go to the documentation of this file.
1 // This is core/vbl/vbl_sort.cxx
2 //:
3 // \file
4 // \author Andrew W. Fitzgibbon, Oxford RRG
5 // \date 19 Nov 97
6 //
7 //-----------------------------------------------------------------------------
8 
9 #include "vbl_sort.h"
10 
11 //: Predicate that will sort doubles in ascending order.
12 int vbl_sort_double_ascending(double const& a, double const& b)
13 {
14  if (a < b)
15  return -1;
16 
17  if (a == b)
18  return 0;
19 
20  return 1;
21 }
22 
23 //: Predicate that will sort in descending order.
24 int vbl_sort_double_descending(double const& a, double const& b)
25 {
26  if (a < b)
27  return 1;
28 
29  if (a == b)
30  return 0;
31 
32  return -1;
33 }
34 
35 //: Ascending integers.
36 int vbl_sort_int_ascending(int const& a, int const& b)
37 {
38  if (a < b)
39  return -1;
40 
41  if (a == b)
42  return 0;
43 
44  return 1;
45 }
46 
47 //: Descending integers.
48 int vbl_sort_int_descending(const int& a, const int& b)
49 {
50  if (a < b)
51  return 1;
52 
53  if (a == b)
54  return 0;
55 
56  return -1;
57 }
58 
60 VBL_SORT_INSTANTIATE(double);
int vbl_sort_double_descending(double const &a, double const &b)
Predicate that will sort in descending order.
Definition: vbl_sort.cxx:23
Collection of common predicates for sorting.
int vbl_sort_double_ascending(double const &a, double const &b)
Predicate that will sort doubles in ascending order.
Definition: vbl_sort.cxx:11
int vbl_sort_int_ascending(int const &a, int const &b)
Ascending integers.
Definition: vbl_sort.cxx:35
int vbl_sort_int_descending(const int &a, const int &b)
Descending integers.
Definition: vbl_sort.cxx:47
VBL_SORT_INSTANTIATE(int)