]> git.mxchange.org Git - simgear.git/blob - simgear/inlines.h
Initial revision.
[simgear.git] / simgear / inlines.h
1 // inlines.h -- various inline template definitions
2 //
3 // Written by Norman Vine, started June 2000.
4 //
5 // Copyright (C) 2000  Norman Vine  - nhv@cape.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _SG_INLINES_H
25 #define _SG_INLINES_H
26
27
28 template <class T>
29 inline const int SG_SIGN(const T x) {
30     return x < T(0) ? -1 : 1;
31 }
32
33 template <class T>
34 inline const T SG_MIN(const T a, const T b) {
35     return a < b ? a : b;
36 }
37
38 // return the minimum of three values
39 template <class T>
40 inline const T SG_MIN3( const T a, const T b, const T c) {
41     return (a < b ? SG_MIN (a, c) : SG_MIN (b, c));
42 }
43
44 template <class T>
45 inline const T SG_MAX(const T a, const T b) {
46     return  a > b ? a : b;
47 }
48
49 // return the maximum of three values
50 template <class T>
51 inline const T SG_MAX3 (const T a, const T b, const T c) {
52     return (a > b ? SG_MAX (a, c) : SG_MAX (b, c));
53 }
54
55 // 
56 template <class T>
57 inline void SG_SWAP( T &a, T &b) {
58     T c = a;  a = b;  b = c;
59 }
60
61 #endif // _SG_INLINES_H