704: Merge oln::internal::fwd_viter_lut and oln::fwd_viter_lut.

https://svn.lrde.epita.fr/svn/oln/trunk/olena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Merge oln::internal::fwd_viter_lut and oln::fwd_viter_lut. * oln/core/internal/fwd_viter_lut.hh: Remove this file, and merge... (oln::internal::fwd_viter_lut): ...this class with... * oln/core/gen/fwd_viter_lut.hh (oln::fwd_viter_lut): ...this one. * oln/Makefile.am (nobase_oln_HEADERS): Remove core/internal/fwd_viter_lut.hh. Makefile.am | 1 core/gen/fwd_viter_lut.hh | 65 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 58 insertions(+), 8 deletions(-) Index: oln/core/gen/fwd_viter_lut.hh --- oln/core/gen/fwd_viter_lut.hh (revision 703) +++ oln/core/gen/fwd_viter_lut.hh (working copy) @@ -28,7 +28,7 @@ #ifndef OLN_CORE_GEN_FWD_VITER_LUT_HH # define OLN_CORE_GEN_FWD_VITER_LUT_HH -# include <oln/core/internal/fwd_viter_lut.hh> +# include <oln/core/abstract/iterator_on_values.hh> # include <oln/core/lookup_table.hh> namespace oln @@ -45,7 +45,7 @@ struct set_super_type< fwd_viter_lut<Lut> > { typedef fwd_viter_lut<Lut> self_t; - typedef internal::fwd_viter_lut<self_t> ret; + typedef abstract::iterator_on_values<self_t> ret; }; @@ -69,19 +69,34 @@ { typedef fwd_viter_lut<Lut> self_t; typedef stc_get_super(self_t) super_t; + typedef oln_type_of(self_t, lut_iter) lut_iter_t; public: - typedef oln_type_of(self_t, lut) lut_t; + typedef oln_type_of(self_t, lut) lut_type; typedef oln_type_of(self_t, value) value_type; public: // Construct an uninitialized value iterator. fwd_viter_lut(const Lut& lut); + /// Iterator manipulators. + /// \{ + void impl_start(); + void impl_next(); + void impl_invalidate(); + bool impl_is_valid() const; + /// \} + // Get the value pointed by this iterator (const version). value_type impl_to_value() const; void print(std::ostream& ostr) const; + + protected: + /// Look-up table. + lut_type& lut_; + /// Iterator on \a lut_. + lut_iter_t i_; }; @@ -94,13 +109,50 @@ # ifndef OLN_INCLUDE_ONLY template <typename Lut> - fwd_viter_lut<Lut>::fwd_viter_lut(const Lut& lut) - : super_t(lut) + fwd_viter_lut<Lut>::fwd_viter_lut(const Lut& lut) : + super_t(), + lut_(lut), + i_() { // Initialize underlying iterator (i.e., \a i_.) this->invalidate(); } + template <typename Exact> + void + fwd_viter_lut<Exact>::impl_start() + { + i_ = lut_.begin(); + } + + template <typename Exact> + void + fwd_viter_lut<Exact>::impl_next() + { + /* Iterate until a different key is reached. In fact, + std::multimap might not be the best choice to implement + new_to_orig_map_. Maybe a std::map binding orig_val to a + std::set of new_val's would is better?. */ + value_type val = i_->first; + do + ++i_; + while (i_ != lut_.end() and i_->first == val); + } + + template <typename Exact> + void + fwd_viter_lut<Exact>::impl_invalidate() + { + i_ = lut_.end(); + } + + template <typename Exact> + bool + fwd_viter_lut<Exact>::impl_is_valid() const + { + return (i_ != lut_.end()); + } + template <typename Lut> typename fwd_viter_lut<Lut>::value_type fwd_viter_lut<Lut>::impl_to_value() const @@ -118,8 +170,7 @@ template <typename Lut> - std::ostream& operator<<(std::ostream& ostr, - const fwd_viter_lut<Lut>& t) + std::ostream& operator<<(std::ostream& ostr, const fwd_viter_lut<Lut>& t) { t.print(ostr); return ostr; Index: oln/Makefile.am --- oln/Makefile.am (revision 703) +++ oln/Makefile.am (working copy) @@ -155,7 +155,6 @@ core/internal/bbox_bkd_piter.hh \ core/internal/bbox_fwd_piter.hh \ core/internal/dpoint_nd.hh \ - core/internal/fwd_viter_lut.hh \ core/internal/point_nd.hh \ core/internal/topology_morpher.hh \ core/internal/tracked_ptr.hh \
participants (1)
-
Roland Levillain