27 #ifndef MLN_HISTO_ARRAY_HH
28 # define MLN_HISTO_ARRAY_HH
37 # include <mln/value/set.hh>
40 # include <mln/convert/from_to.hh>
41 # include <mln/make/box1d.hh>
48 template <
typename T>
struct image1d;
70 const std::vector<unsigned>&
vect()
const;
80 std::vector<unsigned>
h_;
85 std::ostream& operator<<(std::ostream& ostr, const array<T>& h);
88 template <
typename V,
typename T>
91 # ifndef MLN_INCLUDE_ONLY
102 template <
typename T>
104 array<T>::array(
const array& other)
110 template <
typename T>
113 array<T>::operator=(
const array& other)
121 template <
typename T>
129 template <
typename T>
132 array<T>::operator()(
const T& v)
const
134 return h_[s_.index_of(v)];
137 template <
typename T>
140 array<T>::operator()(
const T& v)
142 return h_[s_.index_of(v)];
145 template <
typename T>
148 array<T>::vset()
const
153 template <
typename T>
156 array<T>::operator[](
unsigned i)
const
158 mln_precondition(i < s_.nvalues());
162 template <
typename T>
165 array<T>::operator[](
unsigned i)
167 mln_precondition(i < s_.nvalues());
171 template <
typename T>
173 const std::vector<unsigned>&
174 array<T>::vect()
const
179 template <
typename T>
181 unsigned array<T>::nvalues()
const
186 template <
typename T>
188 std::ostream& operator<<(std::ostream& ostr, const array<T>& h)
193 ostr << v << ':' << h(v) << ' ';
200 template <typename V, typename
T>
203 from_to_(const array<V>& from, image1d<
T>& to)
211 to.init_(make::box1d(from.nvalues()));
212 for (
unsigned i = 0; i < from.nvalues(); ++i)
213 convert::from_to(from[i], to(
point1d(i)));
216 # endif // ! MLN_INCLUDE_ONLY
223 #endif // ! MLN_HISTO_ARRAY_HH