aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 0000000..977645c
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,40 @@
1/*
2 * Copyright (C) 2007-2008 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_UTIL_H
9#define BU_UTIL_H
10
11namespace Bu
12{
13 template<typename item>
14 void swap( item &a, item &b )
15 {
16 item tmp = a;
17 a = b;
18 b = tmp;
19 }
20
21 template<typename item>
22 item &min( item &a, item &b )
23 {
24 return a<b?a:b;
25 }
26
27 template<typename item>
28 item &max( item &a, item &b )
29 {
30 return a>b?a:b;
31 }
32
33 template<typename item>
34 item &mid( item &a, item &b, item &c )
35 {
36 return min( max( a, b ), c );
37 }
38};
39
40#endif