
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Some fixes in graph-related materials. * tests/core/site_set/p_vertices.cc: Layout. (UINT_MAX): Fix warning; use mln_max(unsigned). * tests/core/site_set/p_edges.cc: Likewise. * mln/core/site_set/p_vertices.hh (graph_t): (Re-)New. * mln/core/site_set/p_edges.hh: . It is used so it is featured! * mln/algebra/vec.hh: Upgrade doc style. (operator/): Fix warning with g++-4.3. * mln/util/internal/graph_edge.hh (graph): Fix return sig. * mln/util/internal/graph_vertex.hh: Likewise. * mln/util/internal/graph_edge_psite.hh: Layout. (e): Fix missing update; inherited attr is elt_. * mln/util/internal/graph_vertex_psite.hh: Likewise. * mln/util/internal/graph_psite_base.hh: Layout. (super): Remove; unused. Layout. mln/algebra/vec.hh | 11 +++++------ mln/core/site_set/p_edges.hh | 5 +++++ mln/core/site_set/p_vertices.hh | 4 ++++ mln/util/internal/graph_edge.hh | 6 +++--- mln/util/internal/graph_edge_psite.hh | 15 +++------------ mln/util/internal/graph_psite_base.hh | 12 ++++-------- mln/util/internal/graph_vertex.hh | 6 +++--- mln/util/internal/graph_vertex_psite.hh | 18 ++++-------------- tests/core/site_set/p_edges.cc | 11 +++++++---- tests/core/site_set/p_vertices.cc | 7 +++++-- 10 files changed, 43 insertions(+), 52 deletions(-) Index: tests/core/site_set/p_vertices.cc --- tests/core/site_set/p_vertices.cc (revision 2887) +++ tests/core/site_set/p_vertices.cc (working copy) @@ -34,6 +34,7 @@ #include <mln/core/site_set/p_vertices.hh> #include <mln/fun/i2v/array.hh> + int main() { using namespace mln; @@ -63,6 +64,7 @@ typedef p_vertices<util::graph, F> p_vertices; p_vertices pv(g, f); + // Forward iterator. { mln_fwd_piter_(p_vertices) p(pv); unsigned i = 0; @@ -70,13 +72,14 @@ mln_assertion(p.p_hook_().v().id() == i++); mln_assertion(i == g.v_nmax()); } + + // Backward iterator. { mln_bkd_piter_(p_vertices) p(pv); unsigned i = g.v_nmax() - 1; for_all(p) mln_assertion(p.p_hook_().v().id() == i--); - mln_assertion(i == UINT_MAX); + mln_assertion(i == mln_max(unsigned)); } - return 0; } Index: tests/core/site_set/p_edges.cc --- tests/core/site_set/p_edges.cc (revision 2887) +++ tests/core/site_set/p_edges.cc (working copy) @@ -34,7 +34,9 @@ #include <mln/core/alias/point2d.hh> #include <mln/core/site_set/p_edges.hh> + // Function mapping an edge to a specific site. + template <typename G> struct my_fun { @@ -48,6 +50,7 @@ } }; + int main() { using namespace mln; @@ -72,7 +75,7 @@ typedef p_edges<util::graph, my_fun<util::graph> > p_edges; p_edges pv(g, my_fun<util::graph>()); - // Forward iterator + // Forward iterator. { mln_fwd_piter_(p_edges) p(pv); unsigned i = 0; @@ -80,14 +83,14 @@ mln_assertion(p.p_hook_().e().id() == i++); mln_assertion(i == g.e_nmax()); } - // Backward iterator + + // Backward iterator. { mln_bkd_piter_(p_edges) p(pv); unsigned i = g.e_nmax() - 1; for_all(p) mln_assertion(p.p_hook_().e().id() == i--); - mln_assertion(i == UINT_MAX); + mln_assertion(i == mln_max(unsigned)); } - return 0; } Index: mln/core/site_set/p_vertices.hh --- mln/core/site_set/p_vertices.hh (revision 2887) +++ mln/core/site_set/p_vertices.hh (working copy) @@ -75,6 +75,10 @@ public: + /// Graph associated type. + typedef G graph_t; + + /// Type of graph vertex. typedef util::vertex<G> vertex; Index: mln/core/site_set/p_edges.hh --- mln/core/site_set/p_edges.hh (revision 2887) +++ mln/core/site_set/p_edges.hh (working copy) @@ -39,9 +39,11 @@ namespace mln { + // Forward declaration. template <typename G, typename F> struct p_edges; + namespace trait { template <typename G, typename F> @@ -66,6 +68,9 @@ public: + /// Graph associated type. + typedef G graph_t; + /// Type of graph edge. typedef util::edge<G> edge; Index: mln/algebra/vec.hh --- mln/algebra/vec.hh (revision 2887) +++ mln/algebra/vec.hh (working copy) @@ -1,4 +1,5 @@ // Copyright (C) 2006, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,11 +29,9 @@ #ifndef MLN_ALGEBRA_VEC_HH # define MLN_ALGEBRA_VEC_HH -/*! - * \file mln/algebra/vec.hh - * - * \brief Definition of a generic vector class. - */ +/// \file mln/algebra/vec.hh +/// +/// Definition of a generic vector class. # include <iostream> # include <cmath> @@ -533,7 +532,7 @@ vec<n, mln_trait_op_div(T, S)> operator/(const vec<n,T>& lhs, const mln::value::scalar_<S>& s) { - mln_precondition(value::equiv(s) != literal::zero); + mln_precondition(value::equiv(s) != (S)(literal::zero)); vec<n, mln_trait_op_div(T, S)> tmp; for (unsigned i = 0; i < n; ++i) tmp[i] = lhs[i] / s.to_equiv(); Index: mln/util/internal/graph_edge.hh --- mln/util/internal/graph_edge.hh (revision 2887) +++ mln/util/internal/graph_edge.hh (working copy) @@ -134,7 +134,7 @@ struct subject_impl< const util::edge<G>, E > { unsigned id() const; - const mlc_const(G)& graph() const; + const G& graph() const; unsigned v_other(unsigned id_v) const; bool is_valid() const; unsigned v1() const; @@ -213,7 +213,7 @@ template <typename G> inline - const typename edge<G>::G& + const G& edge<G>::graph() const { return g_; @@ -339,7 +339,7 @@ template <typename G, typename E> inline - const mlc_const(G)& + const G& subject_impl< const util::edge<G>, E >::graph() const { return exact_().get_subject().graph(); Index: mln/util/internal/graph_edge_psite.hh --- mln/util/internal/graph_edge_psite.hh (revision 2887) +++ mln/util/internal/graph_edge_psite.hh (working copy) @@ -72,20 +72,10 @@ }; - } // end of namespace mln::internal - -} // end of namespace mln - # ifndef MLN_INCLUDE_ONLY -namespace mln -{ - - namespace internal - { - template <typename G, typename F> inline edge_psite<G, F>::edge_psite() @@ -111,14 +101,15 @@ const util::edge<G>& edge_psite<G, F>::e() const { - return this->v_; + return this->elt_; } +# endif // ! MLN_INCLUDE_ONLY + } // end of namespace internal } // end of namespace mln -# endif // !MLN_INCLUDE_ONLY #endif // !MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH Index: mln/util/internal/graph_vertex.hh --- mln/util/internal/graph_vertex.hh (revision 2887) +++ mln/util/internal/graph_vertex.hh (working copy) @@ -117,7 +117,7 @@ struct subject_impl< const util::vertex<G>, E > { bool is_valid() const; - const mlc_const(G)& graph() const; + const G& graph() const; unsigned id() const; unsigned other(unsigned id_e) const; @@ -279,7 +279,7 @@ template<typename G> inline - const typename vertex<G>::G& + const G& vertex<G>::graph() const { return g_; @@ -316,7 +316,7 @@ template <typename G, typename E> inline - const mlc_const(G)& + const G& subject_impl< const util::vertex<G>, E >::graph() const { return exact_().get_subject().graph(); Index: mln/util/internal/graph_psite_base.hh --- mln/util/internal/graph_psite_base.hh (revision 2887) +++ mln/util/internal/graph_psite_base.hh (working copy) @@ -32,18 +32,16 @@ /// /// Base implementation for graph based psites. -# include <mln/core/concept/pseudo_site.hh> +# include <mln/core/internal/pseudo_site_base.hh> + + namespace mln { + // Forward declaration. template <typename G, typename F> class p_vertices; -} // end of namespace mln - - -namespace mln -{ namespace internal { @@ -52,8 +50,6 @@ class graph_psite_base : public internal::pseudo_site_base_< const mln_site(S)&, E > { - typedef Pseudo_Site< graph_psite_base<S,E> > super; - public: // This associated type is important to know that this particular Index: mln/util/internal/graph_vertex_psite.hh --- mln/util/internal/graph_vertex_psite.hh (revision 2887) +++ mln/util/internal/graph_vertex_psite.hh (working copy) @@ -66,21 +66,9 @@ }; - } // end of namespace mln::internal - -} // end of namespace mln - - - # ifndef MLN_INCLUDE_ONLY -namespace mln -{ - - namespace internal - { - template <typename G, typename F> inline vertex_psite<G, F>::vertex_psite() @@ -106,13 +94,15 @@ const util::vertex<G>& vertex_psite<G, F>::v() const { - return this->v_; + return this->elt_; } +# endif // ! MLN_INCLUDE_ONLY + } // end of namespace internal } // end of namespace mln -# endif // !MLN_INCLUDE_ONLY + #endif // !MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH