26 #ifndef MLN_HISTO_ARRAY_HH
27 # define MLN_HISTO_ARRAY_HH
36 # include <mln/value/set.hh>
59 unsigned operator()(
const T& v)
const;
60 unsigned& operator()(
const T& v);
62 const std::vector<unsigned>& vect()
const;
64 unsigned operator[](
unsigned i)
const;
65 unsigned& operator[](
unsigned i);
67 unsigned nvalues()
const;
72 std::vector<unsigned> h_;
77 std::ostream& operator<<(std::ostream& ostr, const array<T>& h);
82 # ifndef MLN_INCLUDE_ONLY
87 : s_(mln::value::
set<T>::the()),
95 array<T>::array(
const array& other)
101 template <
typename T>
104 array<T>::operator=(
const array& other)
112 template <
typename T>
117 std::fill(h_.begin(), h_.end(), 0);
120 template <
typename T>
123 array<T>::operator()(
const T& v)
const
125 return h_[s_.index_of(v)];
128 template <
typename T>
131 array<T>::operator()(
const T& v)
133 return h_[s_.index_of(v)];
136 template <
typename T>
139 array<T>::vset()
const
144 template <
typename T>
147 array<T>::operator[](
unsigned i)
const
149 mln_precondition(i < s_.nvalues());
153 template <
typename T>
156 array<T>::operator[](
unsigned i)
158 mln_precondition(i < s_.nvalues());
162 template <
typename T>
164 const std::vector<unsigned>&
165 array<T>::vect()
const
170 template <
typename T>
172 unsigned array<T>::nvalues()
const
177 template <
typename T>
179 std::ostream& operator<<(std::ostream& ostr, const array<T>& h)
184 ostr << v << ':' << h(v) << ' ';
188 # endif // ! MLN_INCLUDE_ONLY
195 #endif // ! MLN_HISTO_ARRAY_HH