CppNoddy  0.92
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CppNoddy::absDiff_predicate< _Type > Class Template Reference

A function object predicate that first computes the absolute difference between two elements and a specified value, then compares these two resulting values. More...

#include <Functors.h>

Inheritance diagram for CppNoddy::absDiff_predicate< _Type >:

Public Member Functions

 absDiff_predicate (_Type value)
 
bool operator() (_Type elt1, _Type elt2)
 Returns true of the first argument is closer to the specified (in constructor) value than the second argument. More...
 

Detailed Description

template<typename _Type>
class CppNoddy::absDiff_predicate< _Type >

A function object predicate that first computes the absolute difference between two elements and a specified value, then compares these two resulting values.

Used for computing which of two components is nearest to the specified value.

Definition at line 30 of file Functors.h.

Constructor & Destructor Documentation

◆ absDiff_predicate()

template<typename _Type >
CppNoddy::absDiff_predicate< _Type >::absDiff_predicate ( _Type  value)
inline
Parameters
valueThe target value that is to used.

Definition at line 33 of file Functors.h.

33 : std::binary_function< _Type, _Type, bool>() {
34 this -> target_elt = value;
35 }

Member Function Documentation

◆ operator()()

template<typename _Type >
bool CppNoddy::absDiff_predicate< _Type >::operator() ( _Type  elt1,
_Type  elt2 
)
inline

Returns true of the first argument is closer to the specified (in constructor) value than the second argument.

Parameters
elt1The first value to be used in the comparison
elt2The second value to be used in the comparison

Definition at line 41 of file Functors.h.

41 {
42 return std::abs(elt2 - target_elt) > std::abs(elt1 - target_elt);
43 }

The documentation for this class was generated from the following file:

© 2012

R.E. Hewitt