DGtal 0.3.0

BasicFunctors.h

Go to the documentation of this file.
00001 
00017 #pragma once
00018 
00033 #if defined(BasicFunctors_RECURSES)
00034 #error Recursive header files inclusion detected in BasicFunctors.h
00035 #else // defined(BasicFunctors_RECURSES)
00036 
00037 #define BasicFunctors_RECURSES
00038 
00039 #if !defined BasicFunctors_h
00040 
00041 #define BasicFunctors_h
00042 
00044 // Inclusions
00045 #include <algorithm>
00046 #include <functional>
00048 
00049 namespace DGtal 
00050 {
00051   template<typename T>
00052   struct MinFunctor
00053   {
00054     inline
00055     T operator() (const T&a, const T&b) const
00056     { return std::min(a,b); }
00057   };
00058   
00059   template<typename T>
00060   struct MaxFunctor
00061   {
00062     inline
00063     T operator() (const T&a, const T&b) const
00064     { return std::max(a,b); }
00065   };
00066 
00070   template <class T> 
00071   struct MinusFunctor : binary_function <T,T,T>
00072   {
00073     T operator() (const T& x, const T& y) const
00074     {return x-y;}
00075   };
00076 
00080   template <class T>
00081   struct AbsFunctor : unary_function<T,T>
00082   { 
00083    inline
00084    T operator() (const T &x) const
00085     {
00086       if (x < 0)
00087         return -x;
00088       else 
00089         return x;
00090     }
00091   };
00092 }
00094 
00095 #endif // !defined BasicFunctors_h
00096 
00097 #undef BasicFunctors_RECURSES
00098 #endif // else defined(BasicFunctors_RECURSES)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines