EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 * SPDX-License-Identifier: EPICS
7 * EPICS BASE is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
19 #ifndef __EPICS_ALGORITHM_H__
20 #define __EPICS_ALGORITHM_H__
21 
22 #include "epicsMath.h"
23 
24 
29 template <class T>
30 inline const T& epicsMin (const T& a, const T& b)
31 {
32  return (b < a) ? b : a;
33 }
34 
41 template <>
42 inline const float& epicsMin (const float& a, const float& b)
43 {
44  return (b < a) || isnan(b) ? b : a;
45 }
46 
53 template <>
54 inline const double& epicsMin (const double& a, const double& b)
55 {
56  return (b < a) || isnan(b) ? b : a;
57 }
58 
63 template <class T>
64 inline const T& epicsMax (const T& a, const T& b)
65 {
66  return (a < b) ? b : a;
67 }
68 
75 template <>
76 inline const float& epicsMax (const float& a, const float& b)
77 {
78  return (a < b) || isnan(b) ? b : a;
79 }
80 
87 template <>
88 inline const double& epicsMax (const double& a, const double& b)
89 {
90  return (a < b) || isnan(b) ? b : a;
91 }
92 
99 template <class T>
100 inline void epicsSwap(T& a, T& b)
101 {
102  T temp = a;
103  a = b;
104  b = temp;
105 }
106 
107 #endif // __EPICS_ALGORITHM_H__
const T & epicsMax(const T &a, const T &b)
void epicsSwap(T &a, T &b)
const T & epicsMin(const T &a, const T &b)