AFF --- A container for numbers (array) by Friederich and Forbriger.
min.h
Go to the documentation of this file.
1 
36 // include guard
37 #ifndef AFF_MIN_H_VERSION
38 
39 #define AFF_MIN_H_VERSION \
40  "AFF_MIN_H V1.1 "
41 
42 
43 #include<aff/lib/collector.h>
44 
45 namespace aff {
46 
47  namespace func {
48 
49  namespace util {
50 
58  template<class C>
59  class Extractmin {
60  typedef typename C::Tcoc Tcont;
61  typedef typename C::Tvalue Tvalue;
62  public:
63  typedef Tvalue Tretval;
65  Extractmin(const Tcont& c): Mval(c(c.first())) { }
67  void operator() (const Tvalue& v)
68  { Mval = Mval < v ? Mval : v; }
70  Tretval result() const { return(Mval); }
71  private:
73  }; // class Extractmin
74 
75  } // namespace util
76 
77 /*----------------------------------------------------------------------*/
78 
89  template<class C>
90  typename C::Tvalue min(const C& c)
91  {
92  return(aff::func::util::collect<C, aff::func::util::Extractmin>(c));
93  } // min()
94 
95  } // namespace func
96 
97 } // namespace aff
98 
99 #endif // AFF_MIN_H_VERSION (includeguard)
100 
101 /* ----- END OF min.h ----- */
Root namespace of library.
Definition: array.h:148
collect values (prototypes)
void operator()(const Tvalue &v)
collect another value
Definition: min.h:67
C::Tvalue min(const C &c)
Definition: min.h:90
Extractmin(const Tcont &c)
initialize member data
Definition: min.h:65
Tretval result() const
return result of operation
Definition: min.h:70