This is Unofficial EPICS BASE Doxygen Site
epicsAlgorithm.h File Reference

Contains a few templates out of the C++ standard header algorithm. More...

#include "epicsMath.h"
+ Include dependency graph for epicsAlgorithm.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class T >
const T & epicsMin (const T &a, const T &b)
 
template<>
const float & epicsMin (const float &a, const float &b)
 
template<>
const double & epicsMin (const double &a, const double &b)
 
template<class T >
const T & epicsMax (const T &a, const T &b)
 
template<>
const float & epicsMax (const float &a, const float &b)
 
template<>
const double & epicsMax (const double &a, const double &b)
 
template<class T >
void epicsSwap (T &a, T &b)
 

Detailed Description

Contains a few templates out of the C++ standard header algorithm.

Author
Jeff Hill & Andrew Johnson
Deprecated:
Use std::min()/max()/swap() in new code

Definition in file epicsAlgorithm.h.

Function Documentation

template<class T >
const T& epicsMax ( const T &  a,
const T &  b 
)
inline

Returns the larger of a or b compared using a<b.

Definition at line 63 of file epicsAlgorithm.h.

64 {
65  return (a < b) ? b : a;
66 }
template<>
const float& epicsMax ( const float &  a,
const float &  b 
)
inline

Returns the larger of a or b compared using a<b.

Note
If b is a NaN the above template returns a, but should return NaN. These specializations ensure that epicsMax(x,NaN) == NaN

Definition at line 75 of file epicsAlgorithm.h.

76 {
77  return (a < b) || isnan(b) ? b : a;
78 }
#define isnan(x)
Definition: epicsMath.h:21
template<>
const double& epicsMax ( const double &  a,
const double &  b 
)
inline

Returns the larger of a or b compared using a<b.

Note
If b is a NaN the above template returns a, but should return NaN. These specializations ensure that epicsMax(x,NaN) == NaN

Definition at line 87 of file epicsAlgorithm.h.

88 {
89  return (a < b) || isnan(b) ? b : a;
90 }
#define isnan(x)
Definition: epicsMath.h:21
template<class T >
const T& epicsMin ( const T &  a,
const T &  b 
)
inline

Returns the smaller of a or b compared using a<b.

Definition at line 29 of file epicsAlgorithm.h.

30 {
31  return (b < a) ? b : a;
32 }
template<>
const float& epicsMin ( const float &  a,
const float &  b 
)
inline

Returns the smaller of a or b compared using a<b.

Note
If b is a NaN the above template returns a, but should return NaN. These specializations ensure that epicsMin(x,NaN) == NaN

Definition at line 41 of file epicsAlgorithm.h.

42 {
43  return (b < a) || isnan(b) ? b : a;
44 }
#define isnan(x)
Definition: epicsMath.h:21
template<>
const double& epicsMin ( const double &  a,
const double &  b 
)
inline

Returns the smaller of a or b compared using a<b.

Note
If b is a NaN the above template returns a, but should return NaN. These specializations ensure that epicsMin(x,NaN) == NaN

Definition at line 53 of file epicsAlgorithm.h.

54 {
55  return (b < a) || isnan(b) ? b : a;
56 }
#define isnan(x)
Definition: epicsMath.h:21
template<class T >
void epicsSwap ( T &  a,
T &  b 
)
inline

Swaps the values of a and b.

Note
The data type must support both copy-construction and assignment.

Definition at line 99 of file epicsAlgorithm.h.

100 {
101  T temp = a;
102  a = b;
103  b = temp;
104 }