diff options
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -28,18 +28,36 @@ namespace Bu | |||
28 | } | 28 | } |
29 | 29 | ||
30 | template<typename item> | 30 | template<typename item> |
31 | const item &min( const item &a, const item &b ) | ||
32 | { | ||
33 | return a<b?a:b; | ||
34 | } | ||
35 | |||
36 | template<typename item> | ||
31 | item &min( item &a, item &b ) | 37 | item &min( item &a, item &b ) |
32 | { | 38 | { |
33 | return a<b?a:b; | 39 | return a<b?a:b; |
34 | } | 40 | } |
35 | 41 | ||
36 | template<typename item> | 42 | template<typename item> |
43 | const item &max( const item &a, const item &b ) | ||
44 | { | ||
45 | return a>b?a:b; | ||
46 | } | ||
47 | |||
48 | template<typename item> | ||
37 | item &max( item &a, item &b ) | 49 | item &max( item &a, item &b ) |
38 | { | 50 | { |
39 | return a>b?a:b; | 51 | return a>b?a:b; |
40 | } | 52 | } |
41 | 53 | ||
42 | template<typename item> | 54 | template<typename item> |
55 | const item &mid( const item &a, const item &b, const item &c ) | ||
56 | { | ||
57 | return min( max( a, b ), c ); | ||
58 | } | ||
59 | |||
60 | template<typename item> | ||
43 | item &mid( item &a, item &b, item &c ) | 61 | item &mid( item &a, item &b, item &c ) |
44 | { | 62 | { |
45 | return min( max( a, b ), c ); | 63 | return min( max( a, b ), c ); |