1915: Complete the overhauling of delta-point pixel iterators.

https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Complete the overhauling of delta-point pixel iterators. * mln/core/dpoints_pixter.hh (mln::dpoints_fwd_pixter<I>::i_) (mln::dpoints_bkd_pixter<I>::i_): Turn indices into iterators. (mln::dpoints_fwd_pixter<I>::update) (mln::dpoints_fwd_pixter<I>::start) (mln::dpoints_fwd_pixter<I>::next_) (mln::dpoints_fwd_pixter<I>::is_valid) (mln::dpoints_fwd_pixter<I>::invalidate) (mln::dpoints_bkd_pixter<I>::update) (mln::dpoints_bkd_pixter<I>::start) (mln::dpoints_bkd_pixter<I>::next_) (mln::dpoints_bkd_pixter<I>::is_valid) (mln::dpoints_bkd_pixter<I>::invalidate): Adjust. * mln/make/pixel.hh: Typos in documentation. core/dpoints_pixter.hh | 32 +++++++++++++++----------------- make/pixel.hh | 10 ++++------ 2 files changed, 19 insertions(+), 23 deletions(-) Index: mln/core/dpoints_pixter.hh --- mln/core/dpoints_pixter.hh (revision 1914) +++ mln/core/dpoints_pixter.hh (working copy) @@ -113,8 +113,7 @@ /// i-1 to pixel i. std::vector<int> offset_; /// Current offset. - // FIXME: Why not an iterator on vector offset_? - unsigned i_; + typename std::vector<int>::const_iterator i_; /// \brief Reference value or pixel. /// @@ -197,8 +196,7 @@ /// from pixel i+1 to pixel i. std::vector<int> offset_; /// Current offset. - // FIXME: Why not an iterator on vector offset_? - int i_; + typename std::vector<int>::const_reverse_iterator i_; /// \brief Reference value or pixel. /// @@ -284,9 +282,9 @@ if (is_valid()) { if (p_ref_) - this->value_ptr_ = & image_(*p_ref_) + offset_[i_]; + this->value_ptr_ = & image_(*p_ref_) + *i_; else - this->value_ptr_ = * value_ref_ + offset_[i_]; + this->value_ptr_ = * value_ref_ + *i_; } } @@ -295,7 +293,7 @@ void dpoints_fwd_pixter<I>::start() { - i_ = 0; + i_ = offset_.begin(); update(); } @@ -306,7 +304,7 @@ { ++i_; if (is_valid()) - this->value_ptr_ += offset_[i_]; + this->value_ptr_ += *i_; } template <typename I> @@ -314,7 +312,7 @@ bool dpoints_fwd_pixter<I>::is_valid() const { - return i_ != offset_.size(); + return i_ != offset_.end(); } template <typename I> @@ -322,7 +320,7 @@ void dpoints_fwd_pixter<I>::invalidate() { - i_ = offset_.size(); + i_ = offset_.end(); } @@ -395,9 +393,9 @@ if (is_valid()) { if (p_ref_) - this->value_ptr_ = & image_(*p_ref_) + offset_[i_]; + this->value_ptr_ = & image_(*p_ref_) + *i_; else - this->value_ptr_ = * value_ref_ + offset_[i_]; + this->value_ptr_ = * value_ref_ + *i_; } } @@ -406,7 +404,7 @@ void dpoints_bkd_pixter<I>::start() { - i_ = offset_.size() - 1; + i_ = offset_.rbegin(); update(); } @@ -415,9 +413,9 @@ void dpoints_bkd_pixter<I>::next_() { - --i_; + ++i_; if (is_valid()) - this->value_ptr_ += offset_[i_]; + this->value_ptr_ += *i_; } template <typename I> @@ -425,7 +423,7 @@ bool dpoints_bkd_pixter<I>::is_valid() const { - return i_ >= 0; + return i_ != offset_.rend(); } template <typename I> @@ -433,7 +431,7 @@ void dpoints_bkd_pixter<I>::invalidate() { - i_ = -1; + i_ = offset_.rend(); } #endif // ! MLN_INCLUDE_ONLY Index: mln/make/pixel.hh --- mln/make/pixel.hh (revision 1914) +++ mln/make/pixel.hh (working copy) @@ -28,10 +28,8 @@ #ifndef MLN_MAKE_PIXEL_HH # define MLN_MAKE_PIXEL_HH -/*! \file mln/make/pixel.hh - * - * \brief Routine to construct an mln::pixel. - */ +/// \file mln/make/pixel.hh +/// \brief Routine to construct an mln::pixel. # include <mln/core/concept/image.hh> # include <mln/core/pixel.hh> @@ -43,11 +41,11 @@ namespace make { - /// Create an mln::pixel from a constant image \p ima and a point \p p. + /// Create a mln::pixel from a constant image \p ima and a point \p p. template <typename I> mln::pixel<const I> pixel(const Image<I>& ima, const mln_point(I)& p); - /// Create an mln::pixel from a mutable image \p ima and a point \p p. + /// Create a mln::pixel from a mutable image \p ima and a point \p p. template <typename I> mln::pixel<I> pixel(Image<I>& ima, const mln_point(I)& p);
participants (1)
-
Roland Levillain