* mln/core/site_set/p_edges.hh,
* mln/core/site_set/p_graph_piter.hh,
* mln/core/site_set/p_vertices.hh,
* mln/util/internal/graph_edge.hh,
* mln/util/internal/graph_iter.hh,
* mln/util/internal/graph_nbh_iter.hh,
* mln/util/internal/graph_nbh_iter_base.hh,
* mln/util/internal/graph_psite_base.hh,
* mln/util/internal/graph_vertex.hh:
Change the method name from g() to graph() and update method calls.
---
milena/ChangeLog | 16 ++++++++
milena/mln/core/site_set/p_edges.hh | 6 +-
milena/mln/core/site_set/p_graph_piter.hh | 2 +-
milena/mln/core/site_set/p_vertices.hh | 47 +++++++++++++++++++---
milena/mln/util/internal/graph_edge.hh | 10 ++--
milena/mln/util/internal/graph_iter.hh | 4 +-
milena/mln/util/internal/graph_nbh_iter.hh | 12 +++---
milena/mln/util/internal/graph_nbh_iter_base.hh | 4 +-
milena/mln/util/internal/graph_psite_base.hh | 2 +-
milena/mln/util/internal/graph_vertex.hh | 10 ++--
10 files changed, 81 insertions(+), 32 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4535ac6..aa7d3fa 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -14,6 +14,22 @@
2008-10-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Use a more explicit name for the method used to retrieve the graph
+ pointer.
+
+ * mln/core/site_set/p_edges.hh,
+ * mln/core/site_set/p_graph_piter.hh,
+ * mln/core/site_set/p_vertices.hh,
+ * mln/util/internal/graph_edge.hh,
+ * mln/util/internal/graph_iter.hh,
+ * mln/util/internal/graph_nbh_iter.hh,
+ * mln/util/internal/graph_nbh_iter_base.hh,
+ * mln/util/internal/graph_psite_base.hh,
+ * mln/util/internal/graph_vertex.hh:
+ Change the method name from g() to graph() and update method calls.
+
+2008-10-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Various small Fixes and cleanup.
* mln/util/internal/graph_edge.hh,
diff --git a/milena/mln/core/site_set/p_edges.hh b/milena/mln/core/site_set/p_edges.hh
index 16d7c45..6a62f8b 100644
--- a/milena/mln/core/site_set/p_edges.hh
+++ b/milena/mln/core/site_set/p_edges.hh
@@ -116,7 +116,7 @@ namespace mln
/// Accessors.
/// \{
/// Return the graph associated to this site set
- const graph_t& g() const;
+ const graph_t& graph() const;
/// Return the mapping function.
F function() const;
/// \}
@@ -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.graph().is_subgraph_of(*g_) && g_->has(e) &&
e.is_valid();
}
template <typename G, typename F>
@@ -223,7 +223,7 @@ namespace mln
template <typename G, typename F>
inline
const typename p_edges<G, F>::graph_t&
- p_edges<G, F>::g() const
+ p_edges<G, F>::graph() const
{
mln_precondition(is_valid());
return *g_;
diff --git a/milena/mln/core/site_set/p_graph_piter.hh
b/milena/mln/core/site_set/p_graph_piter.hh
index da5ae3d..886be0d 100644
--- a/milena/mln/core/site_set/p_graph_piter.hh
+++ b/milena/mln/core/site_set/p_graph_piter.hh
@@ -111,7 +111,7 @@ namespace mln
template <typename S, typename I>
inline
p_graph_piter<S,I>::p_graph_piter(const S& pv)
- : iter_(pv.g())
+ : iter_(pv.graph())
{
this->change_target(pv);
mln_postcondition(!this->is_valid());
diff --git a/milena/mln/core/site_set/p_vertices.hh
b/milena/mln/core/site_set/p_vertices.hh
index 371c581..a54b62a 100644
--- a/milena/mln/core/site_set/p_vertices.hh
+++ b/milena/mln/core/site_set/p_vertices.hh
@@ -73,12 +73,13 @@ namespace mln
public:
/// \brief Construct a graph psite set from a graph of points.
- ///
+ /// \{
+ p_vertices();
+
/// \param gr The graph upon which the graph psite set is built.
- ///
- /// \a gr is \em copied internally, so that the graph psite set is
- /// still valid after the initial graph has been removed.
+ /// \param f the function which maps a vertex to a site.
p_vertices(const graph_t& gr, const F& f);
+ /// \}
/// Associated types.
/// \{
@@ -123,10 +124,16 @@ namespace mln
// FIXME: Dummy.
std::size_t memory_size() const;
+ /// Return the value associated to an element of this site set.
+ /// \{
+ const mln_result(F)& operator()(const psite& p) const;
+ const mln_result(F)& operator()(const util::vertex<G>& p) const;
+ /// \}
+
/// Accessors.
/// \{
/// Return the graph associated to this site set (const version)
- const graph_t& g() const;
+ const graph_t& graph() const;
/// Return the association function.
F function() const;
/// \}
@@ -167,6 +174,13 @@ namespace mln
template <typename G, typename F>
inline
+ p_vertices<G, F>::p_vertices()
+ : f_(0)
+ {
+ }
+
+ template <typename G, typename F>
+ inline
p_vertices<G, F>::p_vertices(const graph_t& g, const F& f)
: g_ (&g), f_(f)
{
@@ -222,7 +236,7 @@ namespace mln
mln_precondition(is_valid());
return
// Check whether P is compatible with this psite set.
- (p.g() == *g_) &&
+ (p.graph() == *g_) &&
// Check that the vertex id of P belongs to the range of valid
// vertex ids.
(p.is_valid());
@@ -240,8 +254,27 @@ namespace mln
template <typename G, typename F>
inline
+ const mln_result(F)&
+ p_vertices<G, F>::operator()(const psite& p) const
+ {
+ mln_precondition(g_.has(p.v()));
+ return (*this)(p.v().id());
+ }
+
+ template <typename G, typename F>
+ inline
+ const mln_result(F)&
+ p_vertices<G, F>::operator()(const util::vertex<G>& v) const
+ {
+ std::cout << v.id() << std::endl;
+ mln_precondition(g_->has_v(v));
+ return f_(v.id());
+ }
+
+ template <typename G, typename F>
+ inline
const typename p_vertices<G, F>::graph_t&
- p_vertices<G, F>::g() const
+ p_vertices<G, F>::graph() const
{
mln_precondition(is_valid());
return *g_;
diff --git a/milena/mln/util/internal/graph_edge.hh
b/milena/mln/util/internal/graph_edge.hh
index 510bfd9..06e39d4 100644
--- a/milena/mln/util/internal/graph_edge.hh
+++ b/milena/mln/util/internal/graph_edge.hh
@@ -74,7 +74,7 @@ namespace mln
void update_id(unsigned id);
/// Return a reference to the graph holding this edge.
- const graph_t& g() const;
+ const graph_t& graph() const;
/// Set g_ with \p g;
void change_graph(const graph_t& g);
@@ -129,7 +129,7 @@ namespace mln
struct subject_impl< const util::edge<G>, E >
{
unsigned id() const;
- const mlc_const(G)& g() const;
+ const mlc_const(G)& graph() const;
unsigned v_other(unsigned id_v) const;
bool is_valid() const;
unsigned v1() const;
@@ -208,7 +208,7 @@ namespace mln
template <typename G>
inline
const typename edge<G>::graph_t&
- edge<G>::g() const
+ edge<G>::graph() const
{
return g_;
}
@@ -329,9 +329,9 @@ namespace mln
template <typename G, typename E>
inline
const mlc_const(G)&
- subject_impl< const util::edge<G>, E >::g() const
+ subject_impl< const util::edge<G>, E >::graph() const
{
- return exact_().get_subject().g();
+ return exact_().get_subject().graph();
}
template <typename G, typename E>
diff --git a/milena/mln/util/internal/graph_iter.hh
b/milena/mln/util/internal/graph_iter.hh
index ab62582..dfd1333 100644
--- a/milena/mln/util/internal/graph_iter.hh
+++ b/milena/mln/util/internal/graph_iter.hh
@@ -207,7 +207,7 @@ namespace mln
unsigned
vertex_bkd_iterator<G>::start_id_() const
{
- return p_.g().v_nmax() - 1;
+ return p_.graph().v_nmax() - 1;
}
template <typename G>
@@ -277,7 +277,7 @@ namespace mln
unsigned
edge_bkd_iterator<G>::start_id_() const
{
- return p_.g().e_nmax() - 1;
+ return p_.graph().e_nmax() - 1;
}
template <typename G>
diff --git a/milena/mln/util/internal/graph_nbh_iter.hh
b/milena/mln/util/internal/graph_nbh_iter.hh
index 5edecef..9b7aa3a 100644
--- a/milena/mln/util/internal/graph_nbh_iter.hh
+++ b/milena/mln/util/internal/graph_nbh_iter.hh
@@ -314,7 +314,7 @@ namespace mln
void
vertex_nbh_vertex_fwd_iterator<G>::invalidate_()
{
- this->i_ = this->p_.g().v_nmax();
+ this->i_ = this->p_.graph().v_nmax();
}
template <typename G>
@@ -367,7 +367,7 @@ namespace mln
void
vertex_nbh_vertex_bkd_iterator<G>::invalidate_()
{
- this->i_ = this->p_.g().v_nmax();
+ this->i_ = this->p_.graph().v_nmax();
}
template <typename G>
@@ -420,7 +420,7 @@ namespace mln
void
vertex_nbh_edge_fwd_iterator<G>::invalidate_()
{
- this->i_ = this->p_.g().e_nmax();
+ this->i_ = this->p_.graph().e_nmax();
}
template <typename G>
@@ -472,7 +472,7 @@ namespace mln
void
vertex_nbh_edge_bkd_iterator<G>::invalidate_()
{
- this->i_ = this->p_.g().e_nmax();
+ this->i_ = this->p_.graph().e_nmax();
}
template <typename G>
@@ -526,7 +526,7 @@ namespace mln
void
edge_nbh_edge_fwd_iterator<G>::invalidate_()
{
- this->i_ = this->p_.g().e_nmax();
+ this->i_ = this->p_.graph().e_nmax();
}
template <typename G>
@@ -588,7 +588,7 @@ namespace mln
void
edge_nbh_edge_bkd_iterator<G>::invalidate_()
{
- this->i_ = this->p_.g().e_nmax();
+ this->i_ = this->p_.graph().e_nmax();
}
template <typename G>
diff --git a/milena/mln/util/internal/graph_nbh_iter_base.hh
b/milena/mln/util/internal/graph_nbh_iter_base.hh
index 8cfcdd6..14950a1 100644
--- a/milena/mln/util/internal/graph_nbh_iter_base.hh
+++ b/milena/mln/util/internal/graph_nbh_iter_base.hh
@@ -90,9 +90,9 @@ namespace mln
template <typename C2>
inline
nbh_iterator_base<G, C, P, E>::nbh_iterator_base(const C2& c)
- : p_(c.g()), i_(0)
+ : p_(c.graph()), i_(0)
{
- //FIXME: Check if typeof(e.g()) == G
+ //FIXME: Check if typeof(c.graph()) == G
center_at(c);
}
diff --git a/milena/mln/util/internal/graph_psite_base.hh
b/milena/mln/util/internal/graph_psite_base.hh
index fa0fb80..5a73135 100644
--- a/milena/mln/util/internal/graph_psite_base.hh
+++ b/milena/mln/util/internal/graph_psite_base.hh
@@ -134,7 +134,7 @@ namespace mln
graph_psite_base<V, P, S, E>::change_target(const target& new_target)
{
t_ = &new_target;
- v_.change_graph(new_target.g());
+ v_.change_graph(new_target.graph());
}
template <typename V, typename P, typename S, typename E>
diff --git a/milena/mln/util/internal/graph_vertex.hh
b/milena/mln/util/internal/graph_vertex.hh
index 61b589f..2de8dde 100644
--- a/milena/mln/util/internal/graph_vertex.hh
+++ b/milena/mln/util/internal/graph_vertex.hh
@@ -82,7 +82,7 @@ namespace mln
void update_id(unsigned id);
/// Returns the graph pointer this vertex belongs to.
- const graph_t& g() const;
+ const graph_t& graph() const;
/// Returns vertex id.
unsigned id() const;
@@ -113,7 +113,7 @@ namespace mln
struct subject_impl< const util::vertex<G>, E >
{
bool is_valid() const;
- const mlc_const(G)& g() const;
+ const mlc_const(G)& graph() const;
unsigned id() const;
unsigned other(unsigned id_e) const;
@@ -275,7 +275,7 @@ namespace mln
template<typename G>
inline
const typename vertex<G>::graph_t&
- vertex<G>::g() const
+ vertex<G>::graph() const
{
return g_;
}
@@ -312,9 +312,9 @@ namespace mln
template <typename G, typename E>
inline
const mlc_const(G)&
- subject_impl< const util::vertex<G>, E >::g() const
+ subject_impl< const util::vertex<G>, E >::graph() const
{
- return exact_().get_subject().g();
+ return exact_().get_subject().graph();
}
template <typename G, typename E>
--
1.5.6.5