AFF --- A container for numbers (array) by Friederich and Forbriger.
absmax.h
Go to the documentation of this file.
1 
36 // include guard
37 #ifndef AFF_ABSMAX_H_VERSION
38 
39 #define AFF_ABSMAX_H_VERSION \
40  "AFF_ABSMAX_H V1.0 "
41 
42 #include<aff/lib/collector.h>
43 
44 namespace aff {
45 
46  namespace func {
47 
48  namespace util {
49 
58  template<class C>
59  class Extractabsmax {
60  typedef typename C::Tcoc Tcont;
61  typedef typename C::Tvalue Tvalue;
62  public:
63  typedef Tvalue Tretval;
65  Extractabsmax(const Tcont& c): Mval(c(c.first()))
66  {
67  if (Mval<0) { Mval = -Mval; }
68  }
70  void operator() (const Tvalue& v)
71  {
72  Tvalue av = v < 0 ? -v : v;
73  Mval = Mval > av ? Mval : av;
74  }
76  Tretval result() const { return(Mval); }
77  private:
79  }; // class Extractabsmax
80 
81  } // namespace util
82 
83 /*----------------------------------------------------------------------*/
84 
97  template<class C>
98  typename C::Tvalue absmax(const C& c)
99  {
100  return(aff::func::util::collect<C, aff::func::util::Extractabsmax>(c));
101  } // absmax()
102 
103  } // namespace func
104 
105 } // namespace aff
106 
107 #endif // AFF_ABSMAX_H_VERSION (includeguard)
108 
109 /* ----- END OF absmax.h ----- */
void operator()(const Tvalue &v)
collect another value
Definition: absmax.h:70
Root namespace of library.
Definition: array.h:148
collect values (prototypes)
C::Tvalue absmax(const C &c)
Definition: absmax.h:98
Tretval result() const
return result of operation
Definition: absmax.h:76
Extractabsmax(const Tcont &c)
initialize member data
Definition: absmax.h:65