26 #ifndef MLN_ACCU_STAT_MAX_H_HH
27 # define MLN_ACCU_STAT_MAX_H_HH
33 # include <mln/accu/internal/base.hh>
34 # include <mln/core/concept/meta_accumulator.hh>
35 # include <mln/accu/histo.hh>
36 # include <mln/util/pix.hh>
45 template <
typename V>
struct max_h;
56 struct accumulator_< accu::stat::max_h<V> >
58 typedef accumulator::has_untake::yes
has_untake;
60 typedef accumulator::has_stop::no
has_stop;
61 typedef accumulator::when_pix::use_v
when_pix;
115 unsigned card()
const {
return h_.sum(); }
152 template <
typename I>
struct max_h< util::pix<I> >;
154 # ifndef MLN_INCLUDE_ONLY
156 template <typename V>
159 max_h<V>::invariant_() const
165 template <
typename V>
175 template <
typename V>
182 this->take_as_init_(t);
194 template <
typename V>
201 for (
unsigned i = this->
card() - 1; i > i_; --i)
203 if (valid_ && sum_ != 0)
209 template <
typename V>
214 mln_precondition(h_(t) != 0);
223 mln_invariant(sum_ >= 1);
228 if (t == t_ && h_[i_] == 0)
233 template <
typename V>
245 mln_postcondition(sum_ == 0);
246 mln_postcondition(h_[i_] != 0);
247 for (
unsigned j = i_ + 1; j < h_.nvalues(); ++j)
248 mln_postcondition(h_[j] == 0);
251 template <
typename V>
266 template <
typename V>
277 template <
typename V>
284 i_ = mln_min(argument);
289 template <
typename V>
301 template <
typename V>
303 const typename max_h<V>::argument&
312 template <
typename V>
314 const accu::histo<V>&
320 template <
typename V>
328 template <
typename V>
333 std::cout <<
"h={" << h_ <<
"} h.sum = " << h_.sum() <<
' ';
334 std::cout <<
"sum=" << sum_ <<
' '
335 <<
"valid=" << valid_ <<
' '
337 <<
"t=" << t_ << std::endl;
340 template <
typename V>
342 std::ostream& operator<<(std::ostream& ostr, const max_h<V>& m)
344 return ostr << m.to_result();
347 # endif // ! MLN_INCLUDE_ONLY
356 #endif // ! MLN_ACCU_STAT_MAX_H_HH