2692: Various small Fixes and cleanup.

* mln/util/internal/graph_edge.hh, * mln/util/internal/graph_base.hh, * mln/core/site_set/p_edges.hh, * mln/core/site_set/p_vertices.hh: fix compilation issues. * mln/fun/i2v/array.hh, * mln/pw/image.hh, * mln/core/site_set/p_graph_piter.hh: cleanup. * mln/util/internal/graph_vertex_psite.hh, * mln/util/graph.hh: fix wrong include. * tests/core/site_set/pset_if.cc: use geom::nsites() instead of estim::nsites(). --- milena/ChangeLog | 19 +++ milena/mln/core/site_set/p_edges.hh | 2 +- milena/mln/core/site_set/p_graph_piter.hh | 140 +----------------------- milena/mln/core/site_set/p_vertices.hh | 6 +- milena/mln/fun/i2v/array.hh | 2 +- milena/mln/pw/image.hh | 2 +- milena/mln/util/graph.hh | 3 +- milena/mln/util/internal/graph_base.hh | 23 +++- milena/mln/util/internal/graph_edge.hh | 2 +- milena/mln/util/internal/graph_vertex_psite.hh | 1 + milena/tests/core/site_set/pset_if.cc | 4 +- 11 files changed, 49 insertions(+), 155 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index b0a73d6..4535ac6 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -14,6 +14,25 @@ 2008-10-26 Guillaume Lazzara <z@lrde.epita.fr> + Various small Fixes and cleanup. + + * mln/util/internal/graph_edge.hh, + * mln/util/internal/graph_base.hh, + * mln/core/site_set/p_edges.hh, + * mln/core/site_set/p_vertices.hh: fix compilation issues. + + * mln/fun/i2v/array.hh, + * mln/pw/image.hh, + * mln/core/site_set/p_graph_piter.hh: cleanup. + + * mln/util/internal/graph_vertex_psite.hh, + * mln/util/graph.hh: fix wrong include. + + * tests/core/site_set/pset_if.cc: use geom::nsites() instead of + estim::nsites(). + +2008-10-26 Guillaume Lazzara <z@lrde.epita.fr> + Change return type of Site_set::nsites() from unsigned to std:size_t. * mln/core/concept/box.hh, diff --git a/milena/mln/core/site_set/p_edges.hh b/milena/mln/core/site_set/p_edges.hh index 3c94998..16d7c45 100644 --- a/milena/mln/core/site_set/p_edges.hh +++ b/milena/mln/core/site_set/p_edges.hh @@ -207,7 +207,7 @@ namespace mln p_edges<G, F>::has(const util::edge<G2>& e) const { mln_precondition(is_valid()); - return e.g()->is_subgraph_of(*g_) && g_->has(e) && e.is_valid(); + return e.g().is_subgraph_of(*g_) && g_->has(e) && e.is_valid(); } template <typename G, typename F> diff --git a/milena/mln/core/site_set/p_graph_piter.hh b/milena/mln/core/site_set/p_graph_piter.hh index 2a235c5..da5ae3d 100644 --- a/milena/mln/core/site_set/p_graph_piter.hh +++ b/milena/mln/core/site_set/p_graph_piter.hh @@ -35,10 +35,6 @@ //# 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. */ - - namespace mln { // Fwd decls. @@ -49,7 +45,7 @@ namespace mln | p_graph_piter<S,I>. | `------------------------*/ - /// \brief Forward iterator on point sites of a mln::S. + /// \brief Generic iterator on point sites of a mln::S. template <typename S, typename I> class p_graph_piter : public internal::site_set_iterator_base< S, @@ -99,66 +95,11 @@ namespace mln operator<<(std::ostream& ostr, const p_graph_piter<S,I>& p); - /*------------------------. - | p_graph_bkd_piter_<S,I>. | - `------------------------*/ - - /// \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< S, - p_graph_bkd_piter_<S,I> > - { - 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 S& pv); - /// \} - - /// Manipulation. - /// \{ - /// Test if the iterator is valid. - bool is_valid_() const; - /// Invalidate the iterator. - void invalidate_(); - - /// Start an iteration. - void start_(); - /// Go to the next point. - void next_(); - /// \} - - 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_<S,I>. - template <typename S, typename I> - inline - std::ostream& - operator<<(std::ostream& ostr, const p_graph_bkd_piter_<S,I>& p); -*/ - - # ifndef MLN_INCLUDE_ONLY - /*------------------------. + /*---------------------. | p_graph_piter<S,I>. | - `------------------------*/ + `---------------------*/ template <typename S, typename I> inline @@ -232,81 +173,6 @@ namespace mln return ostr << p.unproxy_(); } - - /*------------------------. - | p_graph_bkd_piter_<S,I>. | - `------------------------*/ - -/* template <typename S, typename I> - inline - p_graph_bkd_piter_<S,I>::p_graph_bkd_piter_() - { - mln_postcondition(!this->is_valid()); - } - - template <typename S, typename I> - inline - p_graph_bkd_piter_<S,I>::p_graph_bkd_piter_(const S& pv) - : iter_(pv.g()) - { - this->change_target(pv); - mln_postcondition(!this->is_valid()); - } - - template <typename S, typename I> - inline - bool - p_graph_bkd_piter_<S,I>::is_valid_() const - { - return p_.is_valid(); - } - - template <typename S, typename I> - inline - void - p_graph_bkd_piter_<S,I>::invalidate_() - { - p_.invalidate(); - } - - template <typename S, typename I> - inline - void - p_graph_bkd_piter_<S,I>::start_() - { - iter_.start(); - if (this->is_valid()) - update_(); - } - - template <typename S, typename I> - inline - void - p_graph_bkd_piter_<S,I>::next_() - { - 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 S, typename I> - inline - std::ostream& - operator<<(std::ostream& ostr, const p_graph_bkd_piter_<S,I>& p) - { - return ostr << p.unproxy_(); - } -*/ # endif // ! MLN_INCLUDE_ONLY } // end of mln diff --git a/milena/mln/core/site_set/p_vertices.hh b/milena/mln/core/site_set/p_vertices.hh index 461bd51..371c581 100644 --- a/milena/mln/core/site_set/p_vertices.hh +++ b/milena/mln/core/site_set/p_vertices.hh @@ -222,7 +222,7 @@ namespace mln mln_precondition(is_valid()); return // Check whether P is compatible with this psite set. - (p.g() == g_) && + (p.g() == *g_) && // Check that the vertex id of P belongs to the range of valid // vertex ids. (p.is_valid()); @@ -259,10 +259,6 @@ namespace mln bool operator==(const p_vertices<G, F>& lhs, const p_vertices<G, F>& rhs) { - /* FIXME: We should not rely on pointer equality here, as graph - will soon become shells using (shared) tracked pointers to - actual data. So, delegate the equality test to the graphs - themselves. */ return (*lhs.g_) == (*rhs.g_); } diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh index 3fb026c..219be8a 100644 --- a/milena/mln/fun/i2v/array.hh +++ b/milena/mln/fun/i2v/array.hh @@ -62,7 +62,7 @@ namespace mln T operator()(unsigned i) const; T& operator()(unsigned i); - + private: std::vector<T> v_; }; diff --git a/milena/mln/pw/image.hh b/milena/mln/pw/image.hh index 624fc11..ba07d40 100644 --- a/milena/mln/pw/image.hh +++ b/milena/mln/pw/image.hh @@ -259,7 +259,7 @@ namespace mln template <typename F, typename S> inline mln_result(F) - image<F,S>::operator()(const mln_psite(S)& p) const + image<F,S>::operator()(const mln_psite(S)& p) const { mln_precondition(this->data_->pset_.has(p)); return this->data_->f_(p); diff --git a/milena/mln/util/graph.hh b/milena/mln/util/graph.hh index aecb8e9..1cafb19 100644 --- a/milena/mln/util/graph.hh +++ b/milena/mln/util/graph.hh @@ -33,7 +33,7 @@ # include <mln/util/internal/graph_base.hh> # include <mln/util/internal/graph_iter.hh> -# include <mln/util/internal/graph_nbh_iter_base.hh> +# include <mln/util/internal/graph_nbh_iter.hh> # include <mln/util/ord_pair.hh> namespace mln @@ -210,7 +210,6 @@ namespace mln } // end of namespace mln - # ifndef MLN_INCLUDE_ONLY namespace mln diff --git a/milena/mln/util/internal/graph_base.hh b/milena/mln/util/internal/graph_base.hh index d98c6ff..2937258 100644 --- a/milena/mln/util/internal/graph_base.hh +++ b/milena/mln/util/internal/graph_base.hh @@ -125,8 +125,14 @@ namespace mln }; } // end of namespace mln::util::internal + } // End of namespace mln::util + template <typename E> + bool + operator==(const util::internal::graph_base<E>& lhs, + const util::internal::graph_base<E>& rhs); + # ifndef MLN_INCLUDE_ONLY namespace util @@ -186,7 +192,7 @@ namespace mln bool graph_base<E>::has(const util::vertex<E>& v) const { - return has_v(v.id()); + return exact(this)->has_v(v.id()); } /*--------------. @@ -198,7 +204,7 @@ namespace mln bool graph_base<E>::has(const util::edge<E>& e) const { - return has_e(e.id()); + return exact(this)->has_e(e.id()); } /*--------. @@ -216,15 +222,14 @@ namespace mln for (unsigned v = 0; v < g->v_nmax(); ++v) { ostr << "vertex: " << v << std::endl << " -- adjacent vertices: "; - for (int n = 0; n < g->v_nmax_nbh_vertices(v); ++n) + for (unsigned n = 0; n < g->v_nmax_nbh_vertices(v); ++n) ostr << g->v_ith_nbh_vertex(v, n) << " "; ostr << std::endl; } ostr << std::endl; ostr << "edges:" << std::endl; - unsigned ei = 0; - for (int i = 0; i < g->e_nmax(); ++i) + for (unsigned i = 0; i < g->e_nmax(); ++i) ostr << "edge " << i << ": (" << g->v1(i) << ", " << g->v2(i) << " )" @@ -237,6 +242,14 @@ namespace mln # endif // ! MLN_INCLUDE_ONLY + template <typename E> + inline + bool + operator==(const util::internal::graph_base<E>& lhs, + const util::internal::graph_base<E>& rhs) + { + return lhs.graph_id() == rhs.graph_id(); + } } // end of namespace mln diff --git a/milena/mln/util/internal/graph_edge.hh b/milena/mln/util/internal/graph_edge.hh index 42d0e62..510bfd9 100644 --- a/milena/mln/util/internal/graph_edge.hh +++ b/milena/mln/util/internal/graph_edge.hh @@ -170,7 +170,7 @@ namespace mln template <typename G> inline edge<G>::edge() - : g_(0), id_(0) + : id_(0) { } diff --git a/milena/mln/util/internal/graph_vertex_psite.hh b/milena/mln/util/internal/graph_vertex_psite.hh index b0b57cd..3db903c 100644 --- a/milena/mln/util/internal/graph_vertex_psite.hh +++ b/milena/mln/util/internal/graph_vertex_psite.hh @@ -30,6 +30,7 @@ # include <mln/core/concept/pseudo_site.hh> # include <mln/util/internal/graph_psite_base.hh> +# include <mln/util/internal/graph_vertex.hh> namespace mln { diff --git a/milena/tests/core/site_set/pset_if.cc b/milena/tests/core/site_set/pset_if.cc index b4a9469..9918f56 100644 --- a/milena/tests/core/site_set/pset_if.cc +++ b/milena/tests/core/site_set/pset_if.cc @@ -36,7 +36,7 @@ #include <mln/fun/p2b/chess.hh> #include <mln/convert/to_image.hh> #include <mln/convert/to_p_set.hh> -#include <mln/estim/nsites.hh> +#include <mln/geom/nsites.hh> int main() @@ -44,7 +44,7 @@ int main() using namespace mln; box2d box_8x8 = make::box2d(8, 8); - mln_assertion(estim::nsites((box_8x8 | fun::p2b::chess)) == 32); + mln_assertion(geom::nsites((box_8x8 | fun::p2b::chess)) == 32); { p_set<point2d> s = convert::to_p_set(box_8x8 | fun::p2b::chess); -- 1.5.6.5
participants (1)
-
Guillaume Lazzara