This is Unofficial EPICS BASE Doxygen Site
epicsAlgorithm.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
18 #ifndef __EPICS_ALGORITHM_H__
19 #define __EPICS_ALGORITHM_H__
20 
21 #include "epicsMath.h"
22 
23 
28 template <class T>
29 inline const T& epicsMin (const T& a, const T& b)
30 {
31  return (b < a) ? b : a;
32 }
33 
40 template <>
41 inline const float& epicsMin (const float& a, const float& b)
42 {
43  return (b < a) || isnan(b) ? b : a;
44 }
45 
52 template <>
53 inline const double& epicsMin (const double& a, const double& b)
54 {
55  return (b < a) || isnan(b) ? b : a;
56 }
57 
62 template <class T>
63 inline const T& epicsMax (const T& a, const T& b)
64 {
65  return (a < b) ? b : a;
66 }
67 
74 template <>
75 inline const float& epicsMax (const float& a, const float& b)
76 {
77  return (a < b) || isnan(b) ? b : a;
78 }
79 
86 template <>
87 inline const double& epicsMax (const double& a, const double& b)
88 {
89  return (a < b) || isnan(b) ? b : a;
90 }
91 
98 template <class T>
99 inline void epicsSwap(T& a, T& b)
100 {
101  T temp = a;
102  a = b;
103  b = temp;
104 }
105 
106 #endif // __EPICS_ALGORITHM_H__
void epicsSwap(T &a, T &b)
const T & epicsMax(const T &a, const T &b)
#define isnan(x)
Definition: epicsMath.h:21
const T & epicsMin(const T &a, const T &b)