---
milena/mln/core/site_set/p_graph_piter.hh | 181 ++++++++++++++++++-----------
1 files changed, 113 insertions(+), 68 deletions(-)
diff --git a/milena/mln/core/site_set/p_graph_piter.hh
b/milena/mln/core/site_set/p_graph_piter.hh
index 7ef1859..2a235c5 100644
--- a/milena/mln/core/site_set/p_graph_piter.hh
+++ b/milena/mln/core/site_set/p_graph_piter.hh
@@ -32,8 +32,8 @@
/// \brief Definition of point iterator on graph-based point set.
# include <mln/core/internal/site_set_iterator_base.hh>
-# include <mln/core/site_set/p_graph.hh>
-# include <mln/core/image/graph_psite.hh>
+//# include <mln/core/site_set/p_graph.hh>
+//# include <mln/core/image/graph_psite.hh>
/* FIXME: Iterators on p_graph and p_line_graph share common code.
Factor as much as possible. */
@@ -42,28 +42,28 @@
namespace mln
{
// Fwd decls.
- template <typename P> class p_graph;
- template <typename P> class graph_psite;
+ template <typename S, typename I> class graph_psite;
/*------------------------.
- | p_graph_fwd_piter_<P>. |
+ | p_graph_piter<S,I>. |
`------------------------*/
- /// \brief Forward iterator on point sites of a mln::p_graph<P>.
- template <typename P>
- class p_graph_fwd_piter_
- : public internal::site_set_iterator_base< p_graph<P>,
- p_graph_fwd_piter_<P> >
+ /// \brief Forward iterator on point sites of a mln::S.
+ template <typename S, typename I>
+ class p_graph_piter
+ : public internal::site_set_iterator_base< S,
+ p_graph_piter<S, I> >
{
- typedef p_graph_fwd_piter_<P> self_;
- typedef internal::site_set_iterator_base< p_graph<P>, self_ > super_;
+ typedef p_graph_piter<S,I> self_;
+ typedef internal::site_set_iterator_base< S, self_ > super_;
+ typedef I iter;
public:
/// Construction and assignment.
/// \{
- p_graph_fwd_piter_();
- p_graph_fwd_piter_(const p_graph<P>& pg);
+ p_graph_piter();
+ p_graph_piter(const S& pv);
/// \}
/// Manipulation.
@@ -80,36 +80,44 @@ namespace mln
/// \}
private:
+ /// Update the psite corresponding to this iterator.
+ void update_();
+
+ private:
/// The psite corresponding to this iterator.
using super_::p_;
+
+ /// The underlying vertex iterator.
+ iter iter_;
};
- /// Print an mln::p_graph_fwd_piter_<P>.
- template <typename P>
+ /// Print an mln::p_graph_piter<S,I>.
+ template <typename S, typename I>
inline
std::ostream&
- operator<<(std::ostream& ostr, const p_graph_fwd_piter_<P>& p);
+ operator<<(std::ostream& ostr, const p_graph_piter<S,I>& p);
/*------------------------.
- | p_graph_bkd_piter_<P>. |
+ | p_graph_bkd_piter_<S,I>. |
`------------------------*/
- /// \brief Backward iterator on point sites of a mln::p_graph<P>.
- template <typename P>
+ /// \brief Backward iterator on point sites of a mln::S.
+/* template <typename S, typename I>
class p_graph_bkd_piter_
- : public internal::site_set_iterator_base< p_graph<P>,
- p_graph_bkd_piter_<P> >
+ : public internal::site_set_iterator_base< S,
+ p_graph_bkd_piter_<S,I> >
{
- typedef p_graph_bkd_piter_<P> self_;
- typedef internal::site_set_iterator_base< p_graph<P>, self_ > super_;
+ typedef p_graph_bkd_piter_<S,I> self_;
+ typedef internal::site_set_iterator_base< S, self_ > super_;
+ typedef I iter;
public:
/// Construction and assignment.
/// \{
p_graph_bkd_piter_();
- p_graph_bkd_piter_(const p_graph<P>& pg);
+ p_graph_bkd_piter_(const S& pv);
/// \}
/// Manipulation.
@@ -126,142 +134,179 @@ namespace mln
/// \}
private:
+ /// Update the psite corresponding to this iterator.
+ void update_();
+
+ private:
/// The psite corresponding to this iterator.
using super_::p_;
+
+ /// The underlying vertex iterator.
+ iter iter_;
};
- /// Print an mln::p_graph_bkd_piter_<P>.
- template <typename P>
+ /// Print an mln::p_graph_bkd_piter_<S,I>.
+ template <typename S, typename I>
inline
std::ostream&
- operator<<(std::ostream& ostr, const p_graph_bkd_piter_<P>& p);
-
+ operator<<(std::ostream& ostr, const p_graph_bkd_piter_<S,I>& p);
+*/
# ifndef MLN_INCLUDE_ONLY
/*------------------------.
- | p_graph_fwd_piter_<P>. |
+ | p_graph_piter<S,I>. |
`------------------------*/
- template <typename P>
+ template <typename S, typename I>
inline
- p_graph_fwd_piter_<P>::p_graph_fwd_piter_()
+ p_graph_piter<S,I>::p_graph_piter()
{
mln_postcondition(!this->is_valid());
}
- template <typename P>
+ template <typename S, typename I>
inline
- p_graph_fwd_piter_<P>::p_graph_fwd_piter_(const p_graph<P>& pg)
+ p_graph_piter<S,I>::p_graph_piter(const S& pv)
+ : iter_(pv.g())
{
- this->change_target(pg);
+ this->change_target(pv);
mln_postcondition(!this->is_valid());
}
- template <typename P>
+ template <typename S, typename I>
inline
bool
- p_graph_fwd_piter_<P>::is_valid_() const
+ p_graph_piter<S,I>::is_valid_() const
{
- return p_.is_valid();
+ return iter_.is_valid();
}
- template <typename P>
+ template <typename S, typename I>
inline
void
- p_graph_fwd_piter_<P>::invalidate_()
+ p_graph_piter<S,I>::invalidate_()
{
- p_.invalidate();
+ iter_.invalidate();
+ }
+
+ template <typename S, typename I>
+ inline
+ void
+ p_graph_piter<S,I>::start_()
+ {
+ iter_.start();
+ if (this->is_valid())
+ update_();
}
- template <typename P>
+ template <typename S, typename I>
inline
void
- p_graph_fwd_piter_<P>::start_()
+ p_graph_piter<S,I>::next_()
{
- p_.change_vertex_id(0);
+ iter_.next();
+ if (this->is_valid())
+ update_();
}
- template <typename P>
+ template <typename S, typename I>
inline
void
- p_graph_fwd_piter_<P>::next_()
+ p_graph_piter<S,I>::update_()
{
- p_.inc_vertex_id();
+ mln_precondition(this->is_valid());
+ // Update psite_.
+ p_.update_id(iter_.id());
}
- template <typename P>
+
+ template <typename S, typename I>
inline
std::ostream&
- operator<<(std::ostream& ostr, const p_graph_fwd_piter_<P>& p)
+ operator<<(std::ostream& ostr, const p_graph_piter<S,I>& p)
{
return ostr << p.unproxy_();
}
/*------------------------.
- | p_graph_bkd_piter_<P>. |
+ | p_graph_bkd_piter_<S,I>. |
`------------------------*/
- template <typename P>
+/* template <typename S, typename I>
inline
- p_graph_bkd_piter_<P>::p_graph_bkd_piter_()
+ p_graph_bkd_piter_<S,I>::p_graph_bkd_piter_()
{
mln_postcondition(!this->is_valid());
}
- template <typename P>
+ template <typename S, typename I>
inline
- p_graph_bkd_piter_<P>::p_graph_bkd_piter_(const p_graph<P>& pg)
+ p_graph_bkd_piter_<S,I>::p_graph_bkd_piter_(const S& pv)
+ : iter_(pv.g())
{
- this->change_target(pg);
+ this->change_target(pv);
mln_postcondition(!this->is_valid());
}
- template <typename P>
+ template <typename S, typename I>
inline
bool
- p_graph_bkd_piter_<P>::is_valid_() const
+ p_graph_bkd_piter_<S,I>::is_valid_() const
{
return p_.is_valid();
}
- template <typename P>
+ template <typename S, typename I>
inline
void
- p_graph_bkd_piter_<P>::invalidate_()
+ p_graph_bkd_piter_<S,I>::invalidate_()
{
p_.invalidate();
}
- template <typename P>
+ template <typename S, typename I>
inline
void
- p_graph_bkd_piter_<P>::start_()
+ p_graph_bkd_piter_<S,I>::start_()
{
- p_.change_vertex_id(this->site_set().nvertices() - 1);
+ iter_.start();
+ if (this->is_valid())
+ update_();
}
- template <typename P>
+ template <typename S, typename I>
inline
void
- p_graph_bkd_piter_<P>::next_()
+ p_graph_bkd_piter_<S,I>::next_()
{
- p_.dec_vertex_id();
+ iter_.next();
+ if (this->is_valid())
+ update_();
}
+ template <typename S, typename I>
+ inline
+ void
+ p_graph_bkd_piter_<S,I>::update_()
+ {
+ mln_precondition(this->is_valid());
+ // Update psite_.
+ p_.update_id(iter_.id());
+ }
- template <typename P>
+ template <typename S, typename I>
inline
std::ostream&
- operator<<(std::ostream& ostr, const p_graph_bkd_piter_<P>& p)
+ operator<<(std::ostream& ostr, const p_graph_bkd_piter_<S,I>& p)
{
return ostr << p.unproxy_();
}
-
+*/
# endif // ! MLN_INCLUDE_ONLY
} // end of mln
--
1.5.6.5