26 #ifndef MLN_ACCU_HISTO_HH
27 # define MLN_ACCU_HISTO_HH
38 # include <mln/core/concept/value_set.hh>
39 # include <mln/core/concept/meta_accumulator.hh>
40 # include <mln/accu/internal/base.hh>
41 # include <mln/value/set.hh>
42 # include <mln/histo/array.hh>
79 const std::vector<unsigned>&
vect()
const;
80 const std::vector<unsigned>&
to_result()
const;
96 std::ostream& operator<<(std::ostream& ostr, const histo<V>& h);
104 template <
typename V>
116 # ifndef MLN_INCLUDE_ONLY
118 template <
typename V>
126 template <
typename V>
131 ++h_[h_.vset().index_of(t)];
135 template <
typename V>
140 for (
unsigned i = 0; i < h_.nvalues(); ++i)
141 h_[i] += other.h_[i];
145 template <
typename V>
148 histo<V>::untake(
const argument& t)
150 mln_precondition(h_[h_.vset().index_of(t)] > 0);
151 mln_precondition(sum_ > 0);
152 --h_[h_.vset().index_of(t)];
156 template <
typename V>
165 template <
typename V>
168 histo<V>::operator()(
const argument& t)
const
170 return h_[h_.vset().index_of(t)];
173 template <
typename V>
176 histo<V>::operator[](
unsigned i)
const
178 mln_precondition(i < h_.vset().nvalues());
182 template <
typename V>
185 histo<V>::nvalues()
const
187 return h_.vset().nvalues();
190 template <
typename V>
198 template <
typename V>
200 const std::vector<unsigned>&
201 histo<V>::vect()
const
206 template <
typename V>
208 const std::vector<unsigned>&
209 histo<V>::to_result()
const
214 template <
typename V>
217 histo<V>::vset()
const
222 template <
typename V>
224 std::ostream& operator<<(std::ostream& ostr, const histo<V>& h)
226 mln_viter(value::set<V>) v(h.vset());
229 ostr << v << ':' << h(v) << ' ';
233 template <typename V>
236 histo<V>::is_valid()
const
241 # endif // ! MLN_INCLUDE_ONLY
248 #endif // ! MLN_ACCU_HISTO_HH