Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
17 Sep '08
* mln/core/internal/site_set_base.hh: Do it.
---
milena/ChangeLog | 6 ++++++
milena/mln/core/internal/site_set_base.hh | 6 +++++-
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a98db9a..18f27e1 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+ Update the Doxygen documentation of site set internal classes.
+
+ * mln/core/internal/site_set_base.hh: Do it.
+
+2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+
Update line graph image.
* mln/core/image/line_graph_image.hh
diff --git a/milena/mln/core/internal/site_set_base.hh b/milena/mln/core/internal/site_set_base.hh
index 42c0199..de2eaeb 100644
--- a/milena/mln/core/internal/site_set_base.hh
+++ b/milena/mln/core/internal/site_set_base.hh
@@ -46,7 +46,11 @@ namespace mln
/*! \internal A base class for site set classes.
- * \p P is a psite type.
+ *
+ * \arg \p P The psite type of what is ``contained'' in the site
+ * set, not the psite of the site set (which is
+ * different, and defined by the site set itself).
+ * \arg \p E The exact type of the site set.
*/
template <typename P, typename E>
struct site_set_base_ : public Site_Set<E>
--
1.6.0.1
1
0
* mln/core/image/line_graph_image.hh
(mln::line_graph_image<P, V>::operator() const)
(mln::line_graph_image<P, V>::operator()):
Adjust to the new psite interface.
s/id()/edge_id()/.
Adjust preconditions.
---
milena/ChangeLog | 11 +++++++++++
milena/mln/core/image/line_graph_image.hh | 12 ++++++------
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index eaec49e..a98db9a 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+ Update line graph image.
+
+ * mln/core/image/line_graph_image.hh
+ (mln::line_graph_image<P, V>::operator() const)
+ (mln::line_graph_image<P, V>::operator()):
+ Adjust to the new psite interface.
+ s/id()/edge_id()/.
+ Adjust preconditions.
+
+2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+
Update line graph neighborhood & window piters.
* mln/core/internal/line_graph_vicinity_piter.hh
diff --git a/milena/mln/core/image/line_graph_image.hh b/milena/mln/core/image/line_graph_image.hh
index 6770a08..69d9509 100644
--- a/milena/mln/core/image/line_graph_image.hh
+++ b/milena/mln/core/image/line_graph_image.hh
@@ -277,9 +277,9 @@ namespace mln
typename line_graph_image<P, V>::rvalue
line_graph_image<P, V>::operator()(const line_graph_psite<P>& p) const
{
- mln_precondition(p.plg() == this->data_->plg_);
- mln_precondition(p.id() < this->data_->edge_val_.size());
- return this->data_->edge_val_[p.id()];
+ mln_precondition(p.is_valid());
+ mln_precondition(p.site_set() == this->data_->plg_);
+ return this->data_->edge_val_[p.edge_id()];
}
template <typename P, typename V>
@@ -287,9 +287,9 @@ namespace mln
typename line_graph_image<P, V>::lvalue
line_graph_image<P, V>::operator()(const line_graph_psite<P>& p)
{
- mln_precondition(p.plg() == this->data_->plg_);
- mln_precondition(p.id() < this->data_->edge_val_.size());
- return this->data_->edge_val_[p.id()];
+ mln_precondition(p.is_valid());
+ mln_precondition(p.site_set() == this->data_->plg_);
+ return this->data_->edge_val_[p.edge_id()];
}
template <typename P, typename V>
--
1.6.0.1
1
0
* mln/core/internal/line_graph_vicinity_piter.hh
(mln::internal::line_graph_vicinity_piter_<P, S, E>):
Inherit from internal::site_relative_iterator_base.
(line_graph_vicinity_piter_<P, S, E>::line_graph_vicinity_piter_):
New default ctor.
Adjust other ctors.
(mln::internal::line_graph_vicinity_piter_<P, S, E>::super_)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::psite)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::point)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::coord):
Remove typedefs.
(mln::internal::line_graph_vicinity_piter_<P, S, E>::to_point)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::to_psite)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::operator psite)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::p_ref)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::plg)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::p_hook_)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::operator[]):
Remove methods.
(mln::internal::line_graph_vicinity_piter_<P, S, E>::p_ref_)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::saved_p_ref_)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::psite_)
(mln::internal::line_graph_vicinity_piter_<P, S, E>::p_):
Remove attributes.
* mln/core/image/line_graph_neighborhood_piter.hh
* mln/core/image/line_graph_window_piter.hh
(mln::line_graph_neighborhood_fwd_piter<P, N>::psite)
(mln::line_graph_neighborhood_bkd_piter<P, N>::psite)
(mln::line_graph_window_fwd_piter<P, W>::psite)
(mln::line_graph_window_bkd_piter<P, W>::psite):
New typdefs.
(mln::line_graph_neighborhood_fwd_piter<P, N>)
(mln::line_graph_neighborhood_bkd_piter<P, N>)
(mln::line_graph_window_fwd_piter<P, W>)
(mln::line_graph_window_bkd_piter<P, W>):
New default ctors.
Adjust other ctors to the new interface of
mln::line_graph_vicinity_piter_.
(mln::line_graph_neighborhood_fwd_piter<P, N>::is_valid_)
(mln::line_graph_neighborhood_bkd_piter<P, N>::is_valid_)
(mln::line_graph_window_fwd_piter<P, W>::is_valid_)
(mln::line_graph_window_bkd_piter<P, W>::is_valid_):
Adjust to the new interface of mln::line_graph_vicinity_piter_.
(mln::line_graph_neighborhood_fwd_piter<P, N>::start)
(mln::line_graph_neighborhood_bkd_piter<P, N>::start)
(mln::line_graph_window_fwd_piter<P, W>::start)
(mln::line_graph_window_bkd_piter<P, W>::start)
(mln::line_graph_neighborhood_fwd_piter<P, N>::next)
(mln::line_graph_neighborhood_bkd_piter<P, N>::next)
(mln::line_graph_window_fwd_piter<P, W>::next)
(mln::line_graph_window_bkd_piter<P, W>::next):
Likewise.
Rename as...
(mln::line_graph_neighborhood_fwd_piter<P, N>::do_start_)
(mln::line_graph_neighborhood_bkd_piter<P, N>::do_start_)
(mln::line_graph_window_fwd_piter<P, W>::do_start_)
(mln::line_graph_window_bkd_piter<P, W>::do_start_)
(mln::line_graph_neighborhood_fwd_piter<P, N>::do_next_)
(mln::line_graph_neighborhood_bkd_piter<P, N>::do_next_)
(mln::line_graph_window_fwd_piter<P, W>::do_next_)
(mln::line_graph_window_bkd_piter<P, W>::do_next_):
...these.
(mln::line_graph_neighborhood_fwd_piter<P, N>::compute_p_)
(mln::line_graph_neighborhood_bkd_piter<P, N>::compute_p_)
(mln::line_graph_window_fwd_piter<P, W>::compute_p_)
(mln::line_graph_window_bkd_piter<P, W>::compute_p_):
New methods.
(mln::line_graph_neighborhood_fwd_piter<P, N>::site)
(mln::line_graph_neighborhood_bkd_piter<P, N>::site):
Remove typedefs.
(mln::line_graph_neighborhood_fwd_piter<P, N>::update_)
(mln::line_graph_neighborhood_bkd_piter<P, N>::update_)
(mln::line_graph_window_fwd_piter<P, W>::update_)
(mln::line_graph_window_bkd_piter<P, W>::update_)
(mln::line_graph_neighborhood_fwd_piter<P, N>::to_site)
(mln::line_graph_neighborhood_bkd_piter<P, N>::to_site)
(mln::line_graph_neighborhood_fwd_piter<P, N>::operator site)
(mln::line_graph_neighborhood_bkd_piter<P, N>::operator site)
(mln::line_graph_neighborhood_fwd_piter<P, N>::target_)
(mln::line_graph_neighborhood_bkd_piter<P, N>::target_)
(mln::line_graph_neighborhood_fwd_piter<P, N>::change_target)
(mln::line_graph_neighborhood_bkd_piter<P, N>::change_target):
Remove methods.
(mln::line_graph_neighborhood_fwd_piter<P, N>::nbh_)
(mln::line_graph_neighborhood_bkd_piter<P, N>::nbh_)
(mln::line_graph_neighborhood_fwd_piter<P, N>::site_)
(mln::line_graph_neighborhood_bkd_piter<P, N>::site_):
---
milena/ChangeLog | 94 ++++++++
.../core/image/line_graph_neighborhood_piter.hh | 235 ++++----------------
milena/mln/core/image/line_graph_window_piter.hh | 140 +++++-------
.../mln/core/internal/line_graph_vicinity_piter.hh | 119 ++---------
4 files changed, 213 insertions(+), 375 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f41074f..eaec49e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,99 @@
2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+ Update line graph neighborhood & window piters.
+
+ * mln/core/internal/line_graph_vicinity_piter.hh
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>):
+ Inherit from internal::site_relative_iterator_base.
+ (line_graph_vicinity_piter_<P, S, E>::line_graph_vicinity_piter_):
+ New default ctor.
+ Adjust other ctors.
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::super_)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::psite)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::point)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::coord):
+ Remove typedefs.
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::to_point)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::to_psite)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::operator psite)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_ref)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::plg)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_hook_)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::operator[]):
+ Remove methods.
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_ref_)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::saved_p_ref_)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::psite_)
+ (mln::internal::line_graph_vicinity_piter_<P, S, E>::p_):
+ Remove attributes.
+
+ * mln/core/image/line_graph_neighborhood_piter.hh
+ * mln/core/image/line_graph_window_piter.hh
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::psite)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::psite)
+ (mln::line_graph_window_fwd_piter<P, W>::psite)
+ (mln::line_graph_window_bkd_piter<P, W>::psite):
+ New typdefs.
+ (mln::line_graph_neighborhood_fwd_piter<P, N>)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>)
+ (mln::line_graph_window_fwd_piter<P, W>)
+ (mln::line_graph_window_bkd_piter<P, W>):
+ New default ctors.
+ Adjust other ctors to the new interface of
+ mln::line_graph_vicinity_piter_.
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::is_valid_)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::is_valid_)
+ (mln::line_graph_window_fwd_piter<P, W>::is_valid_)
+ (mln::line_graph_window_bkd_piter<P, W>::is_valid_):
+ Adjust to the new interface of mln::line_graph_vicinity_piter_.
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::start)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::start)
+ (mln::line_graph_window_fwd_piter<P, W>::start)
+ (mln::line_graph_window_bkd_piter<P, W>::start)
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::next)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::next)
+ (mln::line_graph_window_fwd_piter<P, W>::next)
+ (mln::line_graph_window_bkd_piter<P, W>::next):
+ Likewise.
+ Rename as...
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::do_start_)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::do_start_)
+ (mln::line_graph_window_fwd_piter<P, W>::do_start_)
+ (mln::line_graph_window_bkd_piter<P, W>::do_start_)
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::do_next_)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::do_next_)
+ (mln::line_graph_window_fwd_piter<P, W>::do_next_)
+ (mln::line_graph_window_bkd_piter<P, W>::do_next_):
+ ...these.
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::compute_p_)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::compute_p_)
+ (mln::line_graph_window_fwd_piter<P, W>::compute_p_)
+ (mln::line_graph_window_bkd_piter<P, W>::compute_p_):
+ New methods.
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::site)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::site):
+ Remove typedefs.
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::update_)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::update_)
+ (mln::line_graph_window_fwd_piter<P, W>::update_)
+ (mln::line_graph_window_bkd_piter<P, W>::update_)
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::to_site)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::to_site)
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::operator site)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::operator site)
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::target_)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::target_)
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::change_target)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::change_target):
+ Remove methods.
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::nbh_)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::nbh_)
+ (mln::line_graph_neighborhood_fwd_piter<P, N>::site_)
+ (mln::line_graph_neighborhood_bkd_piter<P, N>::site_):
+ Remove attributes.
+
+2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+
Update line graph elementary neighborhood and window.
* mln/core/image/line_graph_elt_neighborhood.hh,
diff --git a/milena/mln/core/image/line_graph_neighborhood_piter.hh b/milena/mln/core/image/line_graph_neighborhood_piter.hh
index 69ad4db..c795783 100644
--- a/milena/mln/core/image/line_graph_neighborhood_piter.hh
+++ b/milena/mln/core/image/line_graph_neighborhood_piter.hh
@@ -54,8 +54,13 @@ namespace mln
typedef internal::line_graph_vicinity_piter_<P, N, self_> super_;
public:
+ /// The Point_Site type.
+ typedef mln_psite(N) psite;
+
+ public:
/// Construction.
/// \{
+ line_graph_neighborhood_fwd_piter();
template <typename Pref>
line_graph_neighborhood_fwd_piter(const Neighborhood<N>& nbh,
const Pref& p_ref);
@@ -67,36 +72,17 @@ namespace mln
bool is_valid_() const;
/// Invalidate the iterator.
void invalidate_();
- /// Start an iteration.
- void start_();
+ /// Start an iteration.
+ void do_start_();
/// Go to the next point.
- void next_();
- /// Update the internal data of the iterator.
- void update_();
- /// \}
+ void do_next_();
- /// Conversions.
- /// \{
- /// The corresponding site type.
- typedef P site;
- // FIXME: Dummy.
- site site_;
- // FIXME: Dummy.
- const site& to_site() const;
- // FIXME: Dummy.
- operator site() const;
+ /// Compute the current psite.
+ psite compute_p_() const;
/// \}
- /// Give the target neighborhood address.
- const N*& target_();
- /// Change the target neighborhood.
- void change_target(const N& nbh);
-
private:
- /// The neighborhood.
- const N* nbh_;
-
/// An iterator on the set of adjacent edges.
typename super_::sites_t::const_iterator i_;
};
@@ -116,8 +102,13 @@ namespace mln
typedef internal::line_graph_vicinity_piter_<P, N, self_> super_;
public:
+ /// The Point_Site type.
+ typedef mln_psite(N) psite;
+
+ public:
/// Construction.
/// \{
+ line_graph_neighborhood_bkd_piter();
template <typename Pref>
line_graph_neighborhood_bkd_piter(const Neighborhood<N>& nbh,
const Pref& p_ref);
@@ -129,36 +120,17 @@ namespace mln
bool is_valid_() const;
/// Invalidate the iterator.
void invalidate_();
- /// Start an iteration.
- void start_();
+ /// Start an iteration.
+ void do_start_();
/// Go to the next point.
- void next_();
- /// Update the internal data of the iterator.
- void update_();
- /// \}
+ void do_next_();
- /// Conversions.
- /// \{
- /// The corresponding site type.
- typedef P site;
- // FIXME: Dummy.
- site site_;
- // FIXME: Dummy.
- const site& to_site() const;
- // FIXME: Dummy.
- operator site() const;
+ /// Compute the current psite.
+ psite compute_p_() const;
/// \}
- /// Give the target neighborhood address.
- const N*& target_();
- /// Change the target neighborhood.
- void change_target(const N& nbh);
-
private:
- /// The neighborhood.
- const N* nbh_;
-
/// An iterator on the set of adjacent edges.
typename super_::sites_t::const_reverse_iterator i_;
};
@@ -172,15 +144,19 @@ namespace mln
`------------------------------------------*/
template <typename P, typename N>
+ inline
+ line_graph_neighborhood_fwd_piter<P, N>::line_graph_neighborhood_fwd_piter()
+ {
+ }
+
+ template <typename P, typename N>
template <typename Pref>
inline
line_graph_neighborhood_fwd_piter<P, N>::line_graph_neighborhood_fwd_piter(const Neighborhood<N>& nbh,
const Pref& p_ref)
- : super_(p_ref),
- nbh_(&exact(nbh))
+ : super_(p_ref)
{
- // Invalidate i_.
- this->invalidate();
+ this->change_target(exact(nbh));
}
template <typename P, typename N>
@@ -188,14 +164,7 @@ namespace mln
bool
line_graph_neighborhood_fwd_piter<P, N>::is_valid_() const
{
- return
- // The reference point must be valid...
- this->p_ref_.is_valid()
- // ...and must not have changed since the neighborhood has been
- // computed...
- && this->p_ref_ == this->saved_p_ref_
- // ...and the iterator i_ must point a valid value.
- && i_ != this->sites_.end();
+ return i_ != this->sites_.end();
}
template <typename P, typename N>
@@ -209,96 +178,47 @@ namespace mln
template <typename P, typename N>
inline
void
- line_graph_neighborhood_fwd_piter<P, N>::start_()
+ line_graph_neighborhood_fwd_piter<P, N>::do_start_()
{
- mln_precondition(this->p_ref_.is_valid());
- // Update the neighbors, if needed.
- if (!this->saved_p_ref_.is_valid() || this->p_ref_ != this->saved_p_ref_)
- {
- this->saved_p_ref_ = this->p_ref_;
- nbh_->compute_sites_(*this);
- }
+ this->site_set().compute_sites_(*this);
i_ = this->sites_.begin();
- // FIXME: We might move the is_valid_ condition within update_.
- if (this->is_valid())
- update_();
}
template <typename P, typename N>
inline
void
- line_graph_neighborhood_fwd_piter<P, N>::next_()
+ line_graph_neighborhood_fwd_piter<P, N>::do_next_()
{
- // Ensure the p_ref_ has not changed.
- mln_precondition(this->p_ref_ == this->saved_p_ref_);
++i_;
- // FIXME: We might move the is_valid_ condition within update_.
- if (this->is_valid())
- update_();
}
template <typename P, typename N>
inline
- void
- line_graph_neighborhood_fwd_piter<P, N>::update_()
+ mln_psite(N)
+ line_graph_neighborhood_fwd_piter<P, N>::compute_p_() const
{
- // Update psite_.
- this->psite_ = line_graph_psite<P>(this->plg(), *i_);
+ return line_graph_psite<P>(this->center().site_set(), *i_);
}
- template <typename P, typename N>
- inline
- const P&
- line_graph_neighborhood_fwd_piter<P, N>::to_site() const
- {
- // FIXME: Dummy.
- abort();
- return site_;
- }
-
- template <typename P, typename N>
- inline
- line_graph_neighborhood_fwd_piter<P, N>::operator P() const
- {
- // FIXME: Dummy.
- abort();
- return site_;
- }
-
-
- template <typename P, typename N>
- inline
- const N*&
- line_graph_neighborhood_fwd_piter<P, N>::target_()
- {
- return nbh_;
- }
+ /*------------------------------------------.
+ | line_graph_neighborhood_bkd_piter<P, N>. |
+ `------------------------------------------*/
template <typename P, typename N>
inline
- void line_graph_neighborhood_fwd_piter<P, N>::change_target(const N& nbh)
+ line_graph_neighborhood_bkd_piter<P, N>::line_graph_neighborhood_bkd_piter()
{
- nbh_ = &nbh;
- this->invalidate();
}
-
-
- /*------------------------------------------.
- | line_graph_neighborhood_bkd_piter<P, N>. |
- `------------------------------------------*/
-
template <typename P, typename N>
template <typename Pref>
inline
line_graph_neighborhood_bkd_piter<P, N>::line_graph_neighborhood_bkd_piter(const Neighborhood<N>& nbh,
const Pref& p_ref)
- : super_(p_ref),
- nbh_(&exact(nbh))
+ : super_(p_ref)
{
- // Invalidate i_.
- this->invalidate();
+ this->change_target(exact(nbh));
}
template <typename P, typename N>
@@ -306,14 +226,7 @@ namespace mln
bool
line_graph_neighborhood_bkd_piter<P, N>::is_valid_() const
{
- return
- // The reference point must be valid...
- this->p_ref_.is_valid()
- // ...and must not have changed since the neighborhood has been
- // computed...
- && this->p_ref_ == this->saved_p_ref_
- // ...and the iterator i_ must point a valid value.
- && i_ != this->sites_.rend();
+ return i_ != this->sites_.rend();
}
template <typename P, typename N>
@@ -327,78 +240,26 @@ namespace mln
template <typename P, typename N>
inline
void
- line_graph_neighborhood_bkd_piter<P, N>::start_()
+ line_graph_neighborhood_bkd_piter<P, N>::do_start_()
{
- mln_precondition(this->p_ref_.is_valid());
- // Update the neighbors, if needed.
- if (!this->saved_p_ref_.is_valid() || this->p_ref_ != this->saved_p_ref_)
- {
- this->saved_p_ref_ = this->p_ref_;
- nbh_->compute_sites_(*this);
- }
+ this->site_set().compute_sites_(*this);
i_ = this->sites_.rbegin();
- // FIXME: We might move the is_valid_ condition within update_.
- if (this->is_valid())
- update_();
}
template <typename P, typename N>
inline
void
- line_graph_neighborhood_bkd_piter<P, N>::next_()
+ line_graph_neighborhood_bkd_piter<P, N>::do_next_()
{
- // Ensure the p_ref_ has not changed.
- mln_precondition(this->p_ref_ == this->saved_p_ref_);
++i_;
- // FIXME: We might move the is_valid_ condition within update_.
- if (this->is_valid())
- update_();
- }
-
- template <typename P, typename N>
- inline
- void
- line_graph_neighborhood_bkd_piter<P, N>::update_()
- {
- // Update psite_.
- this->psite_ = line_graph_psite<P>(this->plg(), *i_);
- }
-
-
- template <typename P, typename N>
- inline
- const P&
- line_graph_neighborhood_bkd_piter<P, N>::to_site() const
- {
- // FIXME: Dummy.
- abort();
- return site_;
- }
-
- template <typename P, typename N>
- inline
- line_graph_neighborhood_bkd_piter<P, N>::operator P() const
- {
- // FIXME: Dummy.
- abort();
- return site_;
- }
-
-
- template <typename P, typename N>
- inline
- const N*&
- line_graph_neighborhood_bkd_piter<P, N>::target_()
- {
- return nbh_;
}
template <typename P, typename N>
inline
- void line_graph_neighborhood_bkd_piter<P, N>::change_target(const N& nbh)
+ mln_psite(N)
+ line_graph_neighborhood_bkd_piter<P, N>::compute_p_() const
{
- nbh_ = &nbh;
- this->invalidate();
+ return line_graph_psite<P>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/image/line_graph_window_piter.hh b/milena/mln/core/image/line_graph_window_piter.hh
index 2460f9a..085346c 100644
--- a/milena/mln/core/image/line_graph_window_piter.hh
+++ b/milena/mln/core/image/line_graph_window_piter.hh
@@ -54,11 +54,16 @@ namespace mln
typedef internal::line_graph_vicinity_piter_<P, W, self_> super_;
public:
+ /// The Point_Site type.
+ typedef mln_psite(W) psite;
+
+ public:
/// Construction.
/// \{
+ line_graph_window_fwd_piter();
template <typename Pref>
line_graph_window_fwd_piter(const Window<W>& win,
- const Point_Site<Pref>& p_ref);
+ const Pref& p_ref);
/// \}
/// Manipulation.
@@ -67,19 +72,17 @@ namespace mln
bool is_valid_() const;
/// Invalidate the iterator.
void invalidate_();
- /// Start an iteration.
- void start_();
+ /// Start an iteration.
+ void do_start_();
/// Go to the next point.
- void next_();
- /// Update the internal data of the iterator.
- void update_();
+ void do_next_();
+
+ /// Compute the current psite.
+ psite compute_p_() const;
/// \}
private:
- /// The window.
- const W& win_;
-
/// An iterator on the set of adjacent edges.
typename super_::sites_t::const_iterator i_;
};
@@ -98,11 +101,16 @@ namespace mln
typedef internal::line_graph_vicinity_piter_<P, W, self_> super_;
public:
+ /// The Point_Site type.
+ typedef mln_psite(W) psite;
+
+ public:
/// Construction.
/// \{
+ line_graph_window_bkd_piter();
template <typename Pref>
line_graph_window_bkd_piter(const Window<W>& win,
- const Point_Site<Pref>& p_ref);
+ const Pref& p_ref);
/// \}
/// Manipulation.
@@ -111,19 +119,17 @@ namespace mln
bool is_valid_() const;
/// Invalidate the iterator.
void invalidate_();
- /// Start an iteration.
- void start_();
+ /// Start an iteration.
+ void do_start_();
/// Go to the next point.
- void next_();
- /// Update the internal data of the iterator.
- void update_();
+ void do_next_();
+
+ /// Compute the current psite.
+ psite compute_p_() const;
/// \}
private:
- /// The window.
- const W& win_;
-
/// An iterator on the set of adjacent edges.
typename super_::sites_t::const_reverse_iterator i_;
};
@@ -137,15 +143,19 @@ namespace mln
`------------------------------------*/
template <typename P, typename W>
+ inline
+ line_graph_window_fwd_piter<P, W>::line_graph_window_fwd_piter()
+ {
+ }
+
+ template <typename P, typename W>
template <typename Pref>
inline
line_graph_window_fwd_piter<P, W>::line_graph_window_fwd_piter(const Window<W>& win,
- const Point_Site<Pref>& p_ref)
- : super_(p_ref),
- win_(exact(win))
+ const Pref& p_ref)
+ : super_(p_ref)
{
- // Invalidate i_.
- this->invalidate();
+ this->change_target(exact(win));
}
template <typename P, typename W>
@@ -153,13 +163,7 @@ namespace mln
bool
line_graph_window_fwd_piter<P, W>::is_valid_() const
{
- return
- // The reference point must be valid...
- this->p_ref_.is_valid()
- // ...and must not have changed since the window has been computed...
- && this->p_ref_ == this->saved_p_ref_
- // ...and the iterator i_ must point a valid value.
- && i_ != this->sites_.end();
+ return i_ != this->sites_.end();
}
template <typename P, typename W>
@@ -173,41 +177,26 @@ namespace mln
template <typename P, typename W>
inline
void
- line_graph_window_fwd_piter<P, W>::start_()
+ line_graph_window_fwd_piter<P, W>::do_start_()
{
- mln_precondition(this->p_ref_.is_valid());
- // Update the sites, if needed.
- if (!this->saved_p_ref_.is_valid() || this->p_ref_ != this->saved_p_ref_)
- {
- this->saved_p_ref_ = this->p_ref_;
- win_.compute_sites_(*this);
- }
+ this->site_set().compute_sites_(*this);
i_ = this->sites_.begin();
- // FIXME: We might move the is_valid condition within update_.
- if (this->is_valid())
- update_();
}
template <typename P, typename W>
inline
void
- line_graph_window_fwd_piter<P, W>::next_()
+ line_graph_window_fwd_piter<P, W>::do_next_()
{
- // Ensure the p_ref_ has not changed.
- mln_precondition(this->p_ref_ == this->saved_p_ref_);
++i_;
- // FIXME: We might move the is_valid condition within update_.
- if (this->is_valid())
- update_();
}
template <typename P, typename W>
inline
- void
- line_graph_window_fwd_piter<P, W>::update_()
+ mln_psite(W)
+ line_graph_window_fwd_piter<P, W>::compute_p_() const
{
- // Update psite_.
- this->psite_ = line_graph_psite<P>(this->plg(), *i_);
+ return line_graph_psite<P>(this->center().site_set(), *i_);
}
@@ -216,15 +205,19 @@ namespace mln
`------------------------------------*/
template <typename P, typename W>
+ inline
+ line_graph_window_bkd_piter<P, W>::line_graph_window_bkd_piter()
+ {
+ }
+
+ template <typename P, typename W>
template <typename Pref>
inline
line_graph_window_bkd_piter<P, W>::line_graph_window_bkd_piter(const Window<W>& win,
- const Point_Site<Pref>& p_ref)
- : super_(p_ref),
- win_(exact(win))
+ const Pref& p_ref)
+ : super_(p_ref)
{
- // Invalidate i_.
- this->invalidate();
+ this->change_target(exact(win));
}
template <typename P, typename W>
@@ -232,13 +225,7 @@ namespace mln
bool
line_graph_window_bkd_piter<P, W>::is_valid_() const
{
- return
- // The reference point must be valid...
- this->p_ref_.is_valid()
- // ...and must not have changed since the window has been computed...
- && this->p_ref_ == this->saved_p_ref_
- // ...and the iterator i_ must point a valid value.
- && i_ != this->sites_.rend();
+ return i_ != this->sites_.rend();
}
template <typename P, typename W>
@@ -252,41 +239,26 @@ namespace mln
template <typename P, typename W>
inline
void
- line_graph_window_bkd_piter<P, W>::start_()
+ line_graph_window_bkd_piter<P, W>::do_start_()
{
- mln_precondition(this->p_ref_.is_valid());
- // Update the sites, if needed.
- if (!this->saved_p_ref_.is_valid() || this->p_ref_ != this->saved_p_ref_)
- {
- this->saved_p_ref_ = this->p_ref_;
- win_.compute_sites_(*this);
- }
+ this->site_set().compute_sites_(*this);
i_ = this->sites_.rbegin();
- // FIXME: We might move the is_valid condition within update_.
- if (this->is_valid())
- update_();
}
template <typename P, typename W>
inline
void
- line_graph_window_bkd_piter<P, W>::next_()
+ line_graph_window_bkd_piter<P, W>::do_next_()
{
- // Ensure the p_ref_ has not changed.
- mln_precondition(this->p_ref_ == this->saved_p_ref_);
++i_;
- // FIXME: We might move the is_valid condition within update_.
- if (this->is_valid())
- update_();
}
template <typename P, typename W>
inline
- void
- line_graph_window_bkd_piter<P, W>::update_()
+ mln_psite(W)
+ line_graph_window_bkd_piter<P, W>::compute_p_() const
{
- // Update psite_.
- this->psite_ = line_graph_psite<P>(this->plg(), *i_);
+ return line_graph_psite<P>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/internal/line_graph_vicinity_piter.hh b/milena/mln/core/internal/line_graph_vicinity_piter.hh
index 5a2f699..ffb7616 100644
--- a/milena/mln/core/internal/line_graph_vicinity_piter.hh
+++ b/milena/mln/core/internal/line_graph_vicinity_piter.hh
@@ -39,7 +39,7 @@
# include <set>
-# include <mln/core/concept/site_iterator.hh>
+# include <mln/core/internal/site_relative_iterator_base.hh>
# include <mln/core/site_set/p_line_graph.hh>
# include <mln/core/image/line_graph_psite.hh>
@@ -49,25 +49,22 @@ namespace mln
template <typename P> class p_line_graph;
template <typename P> class line_graph_psite;
+ // FIXME: Consider renaming line_graph_vicinity_piter_ as
+ // line_graph_relative_piter_.
+
namespace internal
{
/// \brief Base for iterator on a line graph vicinity.
template <typename P, typename S, typename E>
class line_graph_vicinity_piter_
- /* FIXME: We should update the interface of this class and inherit
- from internal::site_relative_iterator_base< S, E > instead. */
- : public internal::site_iterator_base< S, E >
+ : public internal::site_relative_iterator_base< S, E >
{
typedef line_graph_vicinity_piter_<P, S, E> self_;
- typedef Site_Iterator< self_ > super_;
public:
enum { dim = P::dim };
- typedef line_graph_psite<P> psite;
- typedef P point;
- typedef mln_coord(point) coord;
// FIXME: Dummy typedef.
typedef void dpoint;
// FIXME: Dummy typedef.
@@ -77,115 +74,46 @@ namespace mln
typedef std::set<util::edge_id> sites_t;
public:
- /// Conversion and accessors.
- /// \{
- /// Reference to the corresponding point.
- const point& to_point() const;
- /// Reference to the corresponding point site.
- const psite& to_psite() const;
- /// Convert the iterator into a line graph psite.
- operator psite() const;
-
- /// Return the reference psite.
- const psite& p_ref() const;
- /// Return the mln::p_line_graph corresponding to this piter.
- const p_line_graph<P>& plg() const;
/// Return the set of sites (adjacent edge ids).
sites_t& sites();
- /* FIXME: Get rid of this as soon as this class inherits from
- internal::site_relative_iterator_base< S, E >. */
- const psite& p_hook_() const;
-
- /// Read-only access to the \a i-th coordinate.
- coord operator[](unsigned i) const;
- /// \}
-
protected:
/// Construction.
/// \{
+ line_graph_vicinity_piter_();
template <typename Pref>
line_graph_vicinity_piter_(const Pref& p_ref);
/// \}
protected:
- /// The ``central'' psite of the vicinity.
- const psite& p_ref_;
-
- /// The last reference psite whose ajacent psites have been computed.
- psite saved_p_ref_;
/// The set of edge ids adjacent to the reference psite.
sites_t sites_;
-
- /// The psite corresponding to this iterator.
- psite psite_;
- /// The point corresponding to this iterator.
- /* FIXME: Dummy value. To be removed as soon as the conversion
- from psite to point is no longer mandatory. */
- point p_;
};
- /* FIXME: This hand-made delegation is painful. We should rely on
- the general mechanism provided by Point_Site. But then again, we
- need to refine/adjust the interface of Point_Site w.r.t. the
- mandatory conversions to points. */
+
+ /// Print a mln::line_graph_vicinity_piter_<P, S, E>.
template <typename P, typename S, typename E>
inline
std::ostream&
- operator<<(std::ostream& ostr, const line_graph_vicinity_piter_<P, S, E>& p);
+ operator<<(std::ostream& ostr,
+ const line_graph_vicinity_piter_<P, S, E>& p);
# ifndef MLN_INCLUDE_ONLY
template <typename P, typename S, typename E>
- template <typename Pref>
- inline
- line_graph_vicinity_piter_<P, S, E>::line_graph_vicinity_piter_(const Pref& p_ref)
- : p_ref_(exact(p_ref)),
- // Initialize psite_ to a dummy value.
- psite_()
- {
- }
-
- template <typename P, typename S, typename E>
- inline
- const P&
- line_graph_vicinity_piter_<P, S, E>::to_point() const
- {
- return p_;
- }
-
- template <typename P, typename S, typename E>
- inline
- const line_graph_psite<P>&
- line_graph_vicinity_piter_<P, S, E>::to_psite() const
- {
- return psite_;
- }
-
- template <typename P, typename S, typename E>
inline
- line_graph_vicinity_piter_<P, S, E>::operator line_graph_psite<P> () const
+ line_graph_vicinity_piter_<P, S, E>::line_graph_vicinity_piter_()
{
- mln_precondition(exact(*this).is_valid());
- return psite_;
- }
-
- template <typename P, typename S, typename E>
- inline
- const line_graph_psite<P>&
- line_graph_vicinity_piter_<P, S, E>::p_ref() const
- {
- return p_ref_;
}
template <typename P, typename S, typename E>
+ template <typename Pref>
inline
- const p_line_graph<P>&
- line_graph_vicinity_piter_<P, S, E>::plg() const
+ line_graph_vicinity_piter_<P, S, E>::line_graph_vicinity_piter_(const Pref& p_ref)
{
- return p_ref_.plg();
+ center_at(p_ref);
}
template <typename P, typename S, typename E>
@@ -196,30 +124,13 @@ namespace mln
return sites_;
}
- template <typename P, typename S, typename E>
- inline
- const line_graph_psite<P>&
- line_graph_vicinity_piter_<P, S, E>::p_hook_() const
- {
- return psite_;
- }
-
- template <typename P, typename S, typename E>
- inline
- mln_coord(P)
- line_graph_vicinity_piter_<P, S, E>::operator[](unsigned i) const
- {
- assert(i < dim);
- return p_[i];
- }
-
template <typename P, typename S, typename E>
inline
std::ostream&
operator<<(std::ostream& ostr, const line_graph_vicinity_piter_<P, S, E>& p)
{
- return ostr << p.to_psite();
+ return ostr << p.unproxy_();
}
# endif // ! MLN_INCLUDE_ONLY
--
1.6.0.1
1
0
17 Sep '08
* mln/core/image/line_graph_elt_neighborhood.hh,
* mln/core/image/line_graph_elt_window.hh
(mln::line_graph_elt_neighborhood<P>::site)
(mln::line_graph_elt_window<P>::site):
Deduce these typedefs from their respective psites.
(mln::line_graph_elt_neighborhood<P>::compute_sites_)
(mln::line_graph_elt_window<P>::compute_sites_):
Adjust to the new psite interface.
s/pref()/center()/.
s/plg()/center().site_set()/.
---
milena/ChangeLog | 15 +++++++++++++++
.../mln/core/image/line_graph_elt_neighborhood.hh | 19 ++++++++++---------
milena/mln/core/image/line_graph_elt_window.hh | 16 +++++++++-------
3 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 763076d..f41074f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,20 @@
2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+ Update line graph elementary neighborhood and window.
+
+ * mln/core/image/line_graph_elt_neighborhood.hh,
+ * mln/core/image/line_graph_elt_window.hh
+ (mln::line_graph_elt_neighborhood<P>::site)
+ (mln::line_graph_elt_window<P>::site):
+ Deduce these typedefs from their respective psites.
+ (mln::line_graph_elt_neighborhood<P>::compute_sites_)
+ (mln::line_graph_elt_window<P>::compute_sites_):
+ Adjust to the new psite interface.
+ s/pref()/center()/.
+ s/plg()/center().site_set()/.
+
+2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a site_set accessor on site_relative_iterator_base.
* mln/core/internal/site_relative_iterator_base.hh
diff --git a/milena/mln/core/image/line_graph_elt_neighborhood.hh b/milena/mln/core/image/line_graph_elt_neighborhood.hh
index 80dc0f3..38b7d8f 100644
--- a/milena/mln/core/image/line_graph_elt_neighborhood.hh
+++ b/milena/mln/core/image/line_graph_elt_neighborhood.hh
@@ -38,7 +38,9 @@
- mln::graph_elt_window
- mln::graph_elt_neighborhood
- mln::line_graph_elt_window
- - mln::line_graph_elt_neighborhood. */
+ - mln::line_graph_elt_neighborhood.
+
+ See https://trac.lrde.org/olena/ticket/139. */
/* FIXME: Due to the poor interface of mln::p_line_graph and
mln::util::graph, we show to much implementation details here.
@@ -70,10 +72,10 @@ namespace mln
public:
/// Associated types.
/// \{
- /// The type of site corresponding to the neighborhood.
- typedef P site;
/// The type of psite corresponding to the neighborhood.
typedef line_graph_psite<P> psite;
+ /// The type of site corresponding to the neighborhood.
+ typedef mln_site(psite) site;
// The type of the set of neighbors (edge ids adjacent to the
// reference psite).
typedef std::set<util::edge_id> sites_t;
@@ -98,7 +100,6 @@ namespace mln
window to_window() const;
/// \}
-
/// Services for iterators.
/// \{
/// Compute the set of sites for this neighborhood around \a piter.
@@ -126,15 +127,15 @@ namespace mln
line_graph_elt_neighborhood<P>::compute_sites_(Site_Iterator<Piter>& piter_) const
{
Piter& piter = exact(piter_);
- util::edge_id ref_edge_id = piter.p_ref().id();
+ util::edge_id ref_edge_id = piter.center().edge_id();
sites_t& sites = piter.sites();
sites.clear();
/* FIXME: Move this computation out of the neighborhood. In fact,
this should be a service of the graph, also proposed by the
p_line_graph. */
// Ajacent edges connected through vertex 1.
- util::vertex_id id1 = piter.p_ref().first_id();
- const util::vertex<P>& vertex1 = piter.plg().gr_->vertex(id1);
+ util::vertex_id id1 = piter.center().first_id();
+ const util::vertex<P>& vertex1 = piter.center().site_set().gr_->vertex(id1);
for (std::vector<util::edge_id>::const_iterator e =
vertex1.edges.begin(); e != vertex1.edges.end(); ++e)
// We explicitly enforce that the reference piter edge id is
@@ -142,8 +143,8 @@ namespace mln
if (*e != ref_edge_id)
sites.insert(*e);
// Ajacent edges connected through vertex 2.
- util::vertex_id id2 = piter.p_ref().second_id();
- const util::vertex<P>& vertex2 = piter.plg().gr_->vertex(id2);
+ util::vertex_id id2 = piter.center().second_id();
+ const util::vertex<P>& vertex2 = piter.center().site_set().gr_->vertex(id2);
for (std::vector<util::edge_id>::const_iterator e =
vertex2.edges.begin(); e != vertex2.edges.end(); ++e)
// Same remark as above.
diff --git a/milena/mln/core/image/line_graph_elt_window.hh b/milena/mln/core/image/line_graph_elt_window.hh
index 04bc542..8649372 100644
--- a/milena/mln/core/image/line_graph_elt_window.hh
+++ b/milena/mln/core/image/line_graph_elt_window.hh
@@ -38,7 +38,9 @@
- mln::graph_elt_window
- mln::graph_elt_neighborhood
- mln::line_graph_elt_window
- - mln::line_graph_elt_neighborhood. */
+ - mln::line_graph_elt_neighborhood.
+
+ See https://trac.lrde.org/olena/ticket/139. */
/* FIXME: Due to the poor interface of mln::p_line_graph and
mln::util::graph, we show to much implementation details here.
@@ -65,10 +67,10 @@ namespace mln
public:
/// Associated types.
/// \{
- /// The type of site corresponding to the window.
- typedef P site;
/// The type of psite corresponding to the window.
typedef line_graph_psite<P> psite;
+ /// The type of site corresponding to the window.
+ typedef mln_site(psite) site;
// The type of the set of window sites (edge ids adjacent to the
// reference psite).
typedef std::set<util::edge_id> sites_t;
@@ -142,14 +144,14 @@ namespace mln
id) itself into SITES, since it is part of the set of edges
adjacent to VERTEX1 and VERTEX2, and will therefore be
automatically added. */
- util::vertex_id id1 = piter.p_ref().first_id();
- const util::vertex<P>& vertex1 = piter.plg().gr_->vertex(id1);
+ util::vertex_id id1 = piter.center().first_id();
+ const util::vertex<P>& vertex1 = piter.center().site_set().gr_->vertex(id1);
for (std::vector<util::edge_id>::const_iterator e =
vertex1.edges.begin(); e != vertex1.edges.end(); ++e)
sites.insert(*e);
// Ajacent edges connected through vertex 2.
- util::vertex_id id2 = piter.p_ref().second_id();
- const util::vertex<P>& vertex2 = piter.plg().gr_->vertex(id2);
+ util::vertex_id id2 = piter.center().second_id();
+ const util::vertex<P>& vertex2 = piter.center().site_set().gr_->vertex(id2);
for (std::vector<util::edge_id>::const_iterator e =
vertex2.edges.begin(); e != vertex2.edges.end(); ++e)
sites.insert(*e);
--
1.6.0.1
1
0
17 Sep '08
* mln/core/internal/site_relative_iterator_base.hh
(mln::internal::site_relative_iterator_base<S, E>::site_set):
New method.
---
milena/ChangeLog | 8 ++++++++
.../core/internal/site_relative_iterator_base.hh | 15 ++++++++++++++-
2 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 75826ef..763076d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a site_set accessor on site_relative_iterator_base.
+
+ * mln/core/internal/site_relative_iterator_base.hh
+ (mln::internal::site_relative_iterator_base<S, E>::site_set):
+ New method.
+
+2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+
Update line graph psite set iterators.
* mln/core/site_set/p_line_graph_piter.hh
diff --git a/milena/mln/core/internal/site_relative_iterator_base.hh b/milena/mln/core/internal/site_relative_iterator_base.hh
index ea30c22..f9b582f 100644
--- a/milena/mln/core/internal/site_relative_iterator_base.hh
+++ b/milena/mln/core/internal/site_relative_iterator_base.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 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
@@ -75,6 +75,10 @@ namespace mln
/// Go to the next point.
void next_();
+ /// Give the site set (neighborhood or window) that this
+ /// iterator browses.
+ const S& site_set() const;
+
/// The psite around which this iterator moves.
const mln_psite(S)& center() const;
@@ -172,6 +176,15 @@ namespace mln
template <typename S, typename E>
inline
+ const S&
+ site_relative_iterator_base<S, E>::site_set() const
+ {
+ mln_precondition(this->s_ != 0);
+ return *this->s_;
+ }
+
+ template <typename S, typename E>
+ inline
const mln_psite(S)&
site_relative_iterator_base<S,E>::subj_()
{
--
1.6.0.1
1
0
* mln/core/site_set/p_line_graph_piter.hh
(mln::p_line_graph_fwd_piter_<P>::super)
(mln::p_line_graph_bkd_piter_<P>::super):
Adjust.
(mln::p_line_graph_fwd_piter_<P>::dim)
(mln::p_line_graph_bkd_piter_<P>::dim)
(mln::p_line_graph_fwd_piter_<P>::point)
(mln::p_line_graph_bkd_piter_<P>::point)
(mln::p_line_graph_fwd_piter_<P>::site)
(mln::p_line_graph_bkd_piter_<P>::psite)
(mln::p_line_graph_fwd_piter_<P>::psite)
(mln::p_line_graph_bkd_piter_<P>::coord)
(mln::p_line_graph_fwd_piter_<P>::coord):
Remove typedefs.
(mln::p_line_graph_fwd_piter<P>::p_line_graph_fwd_piter)
(mln::p_line_graph_bkd_piter<P>::p_line_graph_bkd_piter):
New default ctors.
Remove copy ctors.
(mln::p_line_graph_fwd_piter<P>::is_valid_)
(mln::p_line_graph_bkd_piter<P>::is_valid_)
(mln::p_line_graph_fwd_piter<P>::invalidate_)
(mln::p_line_graph_bkd_piter<P>::invalidate_)
(mln::p_line_graph_fwd_piter<P>::start_)
(mln::p_line_graph_bkd_piter<P>::start_)
(mln::p_line_graph_fwd_piter<P>::next_)
(mln::p_line_graph_bkd_piter<P>::next_):
Adjust w.r.t. the new interface of line_graph_psite.
(operator<<(std::ostream&, const p_line_graph_fwd_piter_<P>&))
(operator<<(std::ostream&, const p_line_graph_bkd_piter_<P>&)):
Likewise.
(mln::p_line_graph_fwd_piter<P>::operator=)
(mln::p_line_graph_bkd_piter<P>::operator=)
(mln::p_line_graph_fwd_piter<P>::update)
(mln::p_line_graph_bkd_piter<P>::update_)
(mln::p_line_graph_fwd_piter<P>::to_point)
(mln::p_line_graph_bkd_piter<P>::to_point)
(mln::p_line_graph_fwd_piter<P>::to_psite)
(mln::p_line_graph_bkd_piter<P>::to_psite)
(mln::p_line_graph_fwd_piter<P>::operator psite)
(mln::p_line_graph_bkd_piter<P>::operator psite)
(mln::p_line_graph_fwd_piter<P>::operator[]):
(mln::p_line_graph_bkd_piter<P>::operator[]):
Remove methods.
(mln::p_line_graph_fwd_piter<P>::plg_)
(mln::p_line_graph_bkd_piter<P>::plg_)
(mln::p_line_graph_fwd_piter<P>::id_)
(mln::p_line_graph_bkd_piter<P>::id_)
(mln::p_line_graph_fwd_piter<P>::psite_):
(mln::p_line_graph_bkd_piter<P>::psite_):
Remove attributes.
(mln::p_line_graph_fwd_piter<P>::p_)
(mln::p_line_graph_bkd_piter<P>::p_):
Get it from super_.
---
milena/ChangeLog | 58 +++++
milena/mln/core/site_set/p_line_graph_piter.hh | 286 +++---------------------
2 files changed, 85 insertions(+), 259 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 856b341..75826ef 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,63 @@
2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+ Update line graph psite set iterators.
+
+ * mln/core/site_set/p_line_graph_piter.hh
+ (mln::p_line_graph_fwd_piter_<P>::super)
+ (mln::p_line_graph_bkd_piter_<P>::super):
+ Adjust.
+ (mln::p_line_graph_fwd_piter_<P>::dim)
+ (mln::p_line_graph_bkd_piter_<P>::dim)
+ (mln::p_line_graph_fwd_piter_<P>::point)
+ (mln::p_line_graph_bkd_piter_<P>::point)
+ (mln::p_line_graph_fwd_piter_<P>::site)
+ (mln::p_line_graph_bkd_piter_<P>::psite)
+ (mln::p_line_graph_fwd_piter_<P>::psite)
+ (mln::p_line_graph_bkd_piter_<P>::coord)
+ (mln::p_line_graph_fwd_piter_<P>::coord):
+ Remove typedefs.
+ (mln::p_line_graph_fwd_piter<P>::p_line_graph_fwd_piter)
+ (mln::p_line_graph_bkd_piter<P>::p_line_graph_bkd_piter):
+ New default ctors.
+ Remove copy ctors.
+ (mln::p_line_graph_fwd_piter<P>::is_valid_)
+ (mln::p_line_graph_bkd_piter<P>::is_valid_)
+ (mln::p_line_graph_fwd_piter<P>::invalidate_)
+ (mln::p_line_graph_bkd_piter<P>::invalidate_)
+ (mln::p_line_graph_fwd_piter<P>::start_)
+ (mln::p_line_graph_bkd_piter<P>::start_)
+ (mln::p_line_graph_fwd_piter<P>::next_)
+ (mln::p_line_graph_bkd_piter<P>::next_):
+ Adjust w.r.t. the new interface of line_graph_psite.
+ (operator<<(std::ostream&, const p_line_graph_fwd_piter_<P>&))
+ (operator<<(std::ostream&, const p_line_graph_bkd_piter_<P>&)):
+ Likewise.
+ (mln::p_line_graph_fwd_piter<P>::operator=)
+ (mln::p_line_graph_bkd_piter<P>::operator=)
+ (mln::p_line_graph_fwd_piter<P>::update)
+ (mln::p_line_graph_bkd_piter<P>::update_)
+ (mln::p_line_graph_fwd_piter<P>::to_point)
+ (mln::p_line_graph_bkd_piter<P>::to_point)
+ (mln::p_line_graph_fwd_piter<P>::to_psite)
+ (mln::p_line_graph_bkd_piter<P>::to_psite)
+ (mln::p_line_graph_fwd_piter<P>::operator psite)
+ (mln::p_line_graph_bkd_piter<P>::operator psite)
+ (mln::p_line_graph_fwd_piter<P>::operator[]):
+ (mln::p_line_graph_bkd_piter<P>::operator[]):
+ Remove methods.
+ (mln::p_line_graph_fwd_piter<P>::plg_)
+ (mln::p_line_graph_bkd_piter<P>::plg_)
+ (mln::p_line_graph_fwd_piter<P>::id_)
+ (mln::p_line_graph_bkd_piter<P>::id_)
+ (mln::p_line_graph_fwd_piter<P>::psite_):
+ (mln::p_line_graph_bkd_piter<P>::psite_):
+ Remove attributes.
+ (mln::p_line_graph_fwd_piter<P>::p_)
+ (mln::p_line_graph_bkd_piter<P>::p_):
+ Get it from super_.
+
+2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+
Update line graph psite set.
* mln/core/site_set/p_line_graph.hh (mln::p_line_graph<P>):
diff --git a/milena/mln/core/site_set/p_line_graph_piter.hh b/milena/mln/core/site_set/p_line_graph_piter.hh
index 23518d6..4971075 100644
--- a/milena/mln/core/site_set/p_line_graph_piter.hh
+++ b/milena/mln/core/site_set/p_line_graph_piter.hh
@@ -53,21 +53,13 @@ namespace mln
p_line_graph_fwd_piter_<P> >
{
typedef p_line_graph_fwd_piter_<P> self_;
- typedef internal::site_iterator_base< P, self_ > super_;
+ typedef internal::site_set_iterator_base< p_line_graph<P>, self_ > super_;
public:
- // Make definitions from super class available.
- enum { dim = super_::dim };
-
- typedef line_graph_psite<P> psite;
- typedef P point;
- typedef mln_coord(point) coord;
-
/// Construction and assignment.
/// \{
+ p_line_graph_fwd_piter_();
p_line_graph_fwd_piter_(const p_line_graph<P>& plg);
- p_line_graph_fwd_piter_(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
/// Manipulation.
@@ -76,47 +68,19 @@ namespace mln
bool is_valid_() const;
/// Invalidate the iterator.
void invalidate_();
+
/// Start an iteration.
void start_();
-
/// Go to the next point.
void next_();
- /// Update the internal data of the iterator.
- void update_();
/// \}
- /// Conversion and accessors.
- /// \{
- /// Reference to the corresponding point.
- // FIXME: Dummy.
- const point& to_point () const;
- /// Reference to the corresponding point site.
- const psite& to_psite () const;
- /// Convert the iterator into a line graph psite.
- operator psite() const;
-
- /// Read-only access to the \a i-th coordinate.
- coord operator[](unsigned i) const;
- /// \}
-
- private:
- /// The p_line_graph this point site belongs to.
- const p_line_graph<P>* plg_;
- /// The id of the edge this psite is pointing towards.
- util::edge_id id_;
- /// The psite corresponding to this iterator.
- psite psite_;
- /// The point corresponding to this iterator.
- /* FIXME: Dummy value. To be removed as soon as the conversion
- from psite to point is no longer mandatory. */
- point p_;
+ protected:
+ using super_::p_;
};
- /* FIXME: This hand-made delegation is painful. We should rely on
- the general mechanism provided by Point_Site. But then again, we
- need to refine/adjust the interface of Point_Site w.r.t. the
- mandatory conversions to points. */
+ /// Print a mln::p_line_graph_fwd_piter_<P>.
template <typename P>
inline
std::ostream&
@@ -134,21 +98,13 @@ namespace mln
p_line_graph_bkd_piter_<P> >
{
typedef p_line_graph_bkd_piter_<P> self_;
- typedef internal::site_iterator_base< P, self_ > super_;
+ typedef internal::site_set_iterator_base< p_line_graph<P>, self_ > super_;
public:
- // Make definitions from super class available.
- enum { dim = super_::dim };
-
- typedef line_graph_psite<P> psite;
- typedef P point;
- typedef mln_coord(point) coord;
-
/// Construction and assignment.
/// \{
+ p_line_graph_bkd_piter_();
p_line_graph_bkd_piter_(const p_line_graph<P>& plg);
- p_line_graph_bkd_piter_(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
/// Manipulation.
@@ -157,47 +113,19 @@ namespace mln
bool is_valid_() const;
/// Invalidate the iterator.
void invalidate_();
+
/// Start an iteration.
void start_();
-
/// Go to the next point.
void next_();
- /// Update the internal data of the iterator.
- void update_();
- /// \}
-
- /// Conversion and accessors.
- /// \{
- /// Reference to the corresponding point.
- // FIXME: Dummy.
- const point& to_point () const;
- /// Reference to the corresponding point site.
- const psite& to_psite () const;
- /// Convert the iterator into a line graph psite.
- operator psite() const;
-
- /// Read-only access to the \a i-th coordinate.
- mln_coord(point) operator[](unsigned i) const;
/// \}
protected:
- /// The p_line_graph this point site belongs to.
- const p_line_graph<P>* plg_;
- /// The id of the edge this psite is pointing towards.
- util::edge_id id_;
- /// The psite corresponding to this iterator.
- psite psite_;
- /// The point corresponding to this iterator.
- /* FIXME: Dummy value. To be removed as soon as the conversion
- from psite to point is no longer mandatory. */
- point p_;
+ using super_::p_;
};
- /* FIXME: This hand-made delegation is painful. We should rely on
- the general mechanism provided by Point_Site. But then again, we
- need to refine/adjust the interface of Point_Site w.r.t. the
- mandatory conversions to points. */
+ /// Print a mln::p_line_graph_bkd_piter_<P>.
template <typename P>
inline
std::ostream&
@@ -212,44 +140,15 @@ namespace mln
template <typename P>
inline
- p_line_graph_fwd_piter_<P>::p_line_graph_fwd_piter_(const p_line_graph<P>& plg)
- : plg_(&plg),
- // Initialize psite_ to a dummy value.
- psite_(plg, -1)
- {
- // Invalidate id_.
- this->invalidate();
- }
-
- template <typename P>
- inline
- p_line_graph_fwd_piter_<P>::p_line_graph_fwd_piter_(const p_line_graph_fwd_piter_<P>& rhs)
- : plg_(rhs.plg_),
- id_(rhs.id_),
- psite_(rhs.psite_)
+ p_line_graph_fwd_piter_<P>::p_line_graph_fwd_piter_()
{
}
template <typename P>
inline
- p_line_graph_fwd_piter_<P>&
- p_line_graph_fwd_piter_<P>::operator=(const p_line_graph_fwd_piter_<P>& rhs)
- {
- if (&rhs == this)
- return *this;
- plg_ = rhs.plg_;
- id_ = rhs.id_;
- psite_ = rhs.psite_;
- return *this;
- }
-
- template <typename P>
- inline
- mln_coord(P)
- p_line_graph_fwd_piter_<P>::operator[](unsigned i) const
+ p_line_graph_fwd_piter_<P>::p_line_graph_fwd_piter_(const p_line_graph<P>& plg)
{
- // Dummy value.
- return p_[i];
+ this->change_target(plg);
}
template <typename P>
@@ -257,7 +156,7 @@ namespace mln
bool
p_line_graph_fwd_piter_<P>::is_valid_() const
{
- return plg_ && id_ < plg_->nedges();
+ return p_.is_valid();
}
template <typename P>
@@ -265,7 +164,7 @@ namespace mln
void
p_line_graph_fwd_piter_<P>::invalidate_()
{
- id_ = -1;
+ p_.invalidate();
}
template <typename P>
@@ -273,9 +172,7 @@ namespace mln
void
p_line_graph_fwd_piter_<P>::start_()
{
- id_ = 0;
- if (this->is_valid())
- update_();
+ p_.change_edge_id(0);
}
template <typename P>
@@ -283,54 +180,7 @@ namespace mln
void
p_line_graph_fwd_piter_<P>::next_()
{
- ++id_.to_equiv();
- if (this->is_valid())
- update_();
- }
-
- template <typename P>
- inline
- void
- p_line_graph_fwd_piter_<P>::update_()
- {
- // Update psite_.
- psite_ = line_graph_psite<P>(*plg_, id_);
- }
-
- template <typename P>
- inline
- const P&
- p_line_graph_fwd_piter_<P>::to_point() const
- {
- // Dummy value.
- return p_;
- }
-
- template <typename P>
- inline
- const line_graph_psite<P>&
- p_line_graph_fwd_piter_<P>::to_psite() const
- {
- /* We don't check whether the iterator is valid before returning
- the value using
-
- mln_precondition(this->is_valid());
-
- since this method may be called *before* the iterator is
- actually initialized. This is the case for instance when this
- point iterator (say, P) is used to initialize another iterator
- on window or neighborhood (say, Q); most of the time, for_all()
- is responsible for the initialization of P, but it takes place
- *after* the creation of Q. */
- return psite_;
- }
-
- template <typename P>
- inline
- p_line_graph_fwd_piter_<P>::operator line_graph_psite<P>() const
- {
- mln_precondition(this->is_valid());
- return psite_;
+ p_.inc_edge_id();
}
@@ -339,9 +189,7 @@ namespace mln
std::ostream&
operator<<(std::ostream& ostr, const p_line_graph_fwd_piter_<P>& p)
{
- // FIXME: We should use p.to_psite() here, but as it lacks the
- // precondition the conversion operator has, we use the latter.
- return ostr << static_cast< line_graph_psite<P> >(p);
+ return ostr << p.unproxy_();
}
@@ -351,46 +199,15 @@ namespace mln
template <typename P>
inline
- p_line_graph_bkd_piter_<P>::p_line_graph_bkd_piter_(const p_line_graph<P>& plg)
- : plg_(&plg),
- // Initialize psite_ to a dummy value.
- psite_(plg, -1)
- {
- // Invalidate id_.
- this->invalidate();
- }
-
- template <typename P>
- inline
- p_line_graph_bkd_piter_<P>::p_line_graph_bkd_piter_(const p_line_graph_bkd_piter_<P>& rhs)
- : plg_(rhs.plg_),
- id_(rhs.id_),
- psite_(rhs.psite_)
- {
- }
-
- template <typename P>
- inline
- p_line_graph_bkd_piter_<P>&
- p_line_graph_bkd_piter_<P>::operator=(const p_line_graph_bkd_piter_<P>& rhs)
+ p_line_graph_bkd_piter_<P>::p_line_graph_bkd_piter_()
{
- if (&rhs == this)
- return *this;
- plg_ = rhs.plg_;
- id_ = rhs.id_;
- psite_ = rhs.psite_;
- // FIXME: Probably superfluous.
-// update_();
- return *this;
}
template <typename P>
inline
- mln_coord(P)
- p_line_graph_bkd_piter_<P>::operator[](unsigned i) const
+ p_line_graph_bkd_piter_<P>::p_line_graph_bkd_piter_(const p_line_graph<P>& plg)
{
- // Dummy value.
- return p_[i];
+ this->change_target(plg);
}
template <typename P>
@@ -398,7 +215,7 @@ namespace mln
bool
p_line_graph_bkd_piter_<P>::is_valid_() const
{
- return plg_ && id_ < plg_->nedges();
+ return p_.is_valid();
}
template <typename P>
@@ -406,7 +223,7 @@ namespace mln
void
p_line_graph_bkd_piter_<P>::invalidate_()
{
- id_ = -1;
+ p_.set_id(this->site_set().nedges());
}
template <typename P>
@@ -414,9 +231,7 @@ namespace mln
void
p_line_graph_bkd_piter_<P>::start_()
{
- id_ = plg_->nedges() - 1;
- if (this->is_valid())
- update_();
+ p_.set_id(this->site_set().nedges() - 1);
}
template <typename P>
@@ -424,54 +239,7 @@ namespace mln
void
p_line_graph_bkd_piter_<P>::next_()
{
- --id_.to_equiv();
- if (this->is_valid())
- update_();
- }
-
- template <typename P>
- inline
- void
- p_line_graph_bkd_piter_<P>::update_()
- {
- // Update psite_.
- psite_ = line_graph_psite<P>(*plg_, id_);
- }
-
- template <typename P>
- inline
- const P&
- p_line_graph_bkd_piter_<P>::to_point() const
- {
- // Dummy value.
- return p_;
- }
-
- template <typename P>
- inline
- const line_graph_psite<P>&
- p_line_graph_bkd_piter_<P>::to_psite() const
- {
- /* We don't check whether the iterator is valid before returning
- the value using
-
- mln_precondition(this->is_valid());
-
- since this method may be called *before* the iterator is
- actually initialized. This is the case for instance when this
- point iterator (say, P) is used to initialize another iterator
- on window or neighborhood (say, Q); most of the time, for_all()
- is responsible for the initialization of P, but it takes place
- *after* the creation of Q. */
- return psite_;
- }
-
- template <typename P>
- inline
- p_line_graph_bkd_piter_<P>::operator line_graph_psite<P>() const
- {
- mln_precondition(this->is_valid());
- return psite_;
+ p_.dec_edge_id();
}
@@ -480,7 +248,7 @@ namespace mln
std::ostream&
operator<<(std::ostream& ostr, const p_line_graph_bkd_piter_<P>& p)
{
- return ostr << static_cast< line_graph_psite<P> >(p);
+ return ostr << p.unproxy_();
}
# endif // ! MLN_INCLUDE_ONLY
--
1.6.0.1
1
0
* mln/core/site_set/p_line_graph.hh (mln::p_line_graph<P>):
Inherit from
internal::site_set_base_< site_pair<P>, p_line_graph<P> >.
(mln::p_line_graph<P>::self_)
(mln::p_line_graph<P>::super_):
New typedefs.
(mln::p_line_graph<P>::site): Remove typedef.
(mln::p_line_graph<P>::element): Define as mln_site(super_).
(mln::p_line_graph<P>::nsites): Set return type to unsigned.
(mln::p_line_graph<P>::has): Update w.r.t. the new interface of
mln::line_graph_psite.
* mln/core/concept/site_set.hh
(site_set_nsites_check<mln::trait::site_set::nsites::known, E>::run):
Add a FIXME.
---
milena/ChangeLog | 19 ++++++++++++++++++
milena/mln/core/concept/site_set.hh | 1 +
milena/mln/core/site_set/p_line_graph.hh | 31 +++++++++++++++++++++--------
3 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ae13b3c..856b341 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,24 @@
2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+ Update line graph psite set.
+
+ * mln/core/site_set/p_line_graph.hh (mln::p_line_graph<P>):
+ Inherit from
+ internal::site_set_base_< site_pair<P>, p_line_graph<P> >.
+ (mln::p_line_graph<P>::self_)
+ (mln::p_line_graph<P>::super_):
+ New typedefs.
+ (mln::p_line_graph<P>::site): Remove typedef.
+ (mln::p_line_graph<P>::element): Define as mln_site(super_).
+ (mln::p_line_graph<P>::nsites): Set return type to unsigned.
+ (mln::p_line_graph<P>::has): Update w.r.t. the new interface of
+ mln::line_graph_psite.
+ * mln/core/concept/site_set.hh
+ (site_set_nsites_check<mln::trait::site_set::nsites::known, E>::run):
+ Add a FIXME.
+
+2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+
Update line graph psite.
* mln/core/image/line_graph_psite.hh
diff --git a/milena/mln/core/concept/site_set.hh b/milena/mln/core/concept/site_set.hh
index 2e9d4b7..40b288e 100644
--- a/milena/mln/core/concept/site_set.hh
+++ b/milena/mln/core/concept/site_set.hh
@@ -186,6 +186,7 @@ namespace mln
{
static void run()
{
+ // FIXME: Return type should be std::size_t.
unsigned (E::*m)() const = & E::nsites;
m = 0;
}
diff --git a/milena/mln/core/site_set/p_line_graph.hh b/milena/mln/core/site_set/p_line_graph.hh
index 036cfef..548b9e2 100644
--- a/milena/mln/core/site_set/p_line_graph.hh
+++ b/milena/mln/core/site_set/p_line_graph.hh
@@ -28,6 +28,8 @@
#ifndef MLN_CORE_SITE_SET_P_LINE_GRAPH_HH
# define MLN_CORE_SITE_SET_P_LINE_GRAPH_HH
+# include <mln/util/site_pair.hh>
+
# include <mln/core/concept/point_site.hh>
# include <mln/core/internal/site_set_base.hh>
# include <mln/accu/bbox.hh>
@@ -47,6 +49,7 @@
namespace mln
{
+
// Forward declaration.
template<typename P> struct p_line_graph;
@@ -69,8 +72,11 @@ namespace mln
template<typename P>
struct p_line_graph
- : public internal::site_set_base_< line_graph_psite<P>, p_line_graph<P> >
+ : public internal::site_set_base_< site_pair<P>, p_line_graph<P> >
{
+ typedef p_line_graph<P> self_;
+ typedef internal::site_set_base_< site_pair<P>, self_ > super_;
+
typedef util::graph<P> graph;
/// \brief Construct a line graph psite set from a graph of points.
@@ -84,10 +90,7 @@ namespace mln
/// Associated types.
/// \{
/// Element associated type.
- typedef P element;
-
- /// Site associated type.
- typedef P site;
+ typedef mln_site(super_) element;
/// Point_Site associated type.
typedef line_graph_psite<P> psite;
@@ -107,7 +110,9 @@ namespace mln
/// line graph.
///
/// Required by the mln::Point_Set concept.
- std::size_t nsites() const;
+ /* FIXME: Return type should be std::size_t (see
+ mln/core/concept/site_set.hh). */
+ unsigned nsites() const;
/// Return The number of vertices in the graph.
std::size_t nvertices() const;
@@ -160,6 +165,10 @@ namespace mln
bool
operator==(const p_line_graph<P>& lhs, const p_line_graph<P>& rhs);
+
+ /* FIXME: Extend the `ord' mechanism instead of this ill-defined
+ pseudo-order. */
+
/// \brief Inclusion of a mln::p_line_graph in another one.
///
/// This inclusion relation is very strict for the moment, since our
@@ -189,7 +198,7 @@ namespace mln
template <typename P>
inline
- std::size_t
+ unsigned
p_line_graph<P>::nsites() const
{
return nedges();
@@ -235,9 +244,9 @@ namespace mln
{
return
// Check whether P is compatible with this psite set.
- (&p.plg() == this) &&
+ (p.target_() == this) &&
// Check that the edge id of P belongs to the range of valid edge ids.
- (p.id() < gr_->nedges());
+ (p.is_valid());
}
template <typename P>
@@ -317,6 +326,10 @@ namespace mln
bool
operator==(const p_line_graph<P>& lhs, const p_line_graph<P>& 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.gr_.ptr_ == rhs.gr_.ptr_;
}
--
1.6.0.1
1
0
* mln/core/image/line_graph_psite.hh
(mln::line_graph_psite<P>): Inherit from
mln::internal::pseudo_site_base_.
(mln::line_graph_psite<P>::line_graph_psite):
Adjust ctors.
(mln::line_graph_psite<P>::first)
(mln::line_graph_psite<P>::second)
(mln::line_graph_psite<P>::first_id)
(mln::line_graph_psite<P>::second_id):
Adjust methods.
(operator==(const line_graph_psite<P>&, const line_graph_psite<P>&))
(operator< (const line_graph_psite<P>&, const line_graph_psite<P>&)):
Adjust operators.
(mln::line_graph_psite<P>::super_): Adjust.
(mln::line_graph_psite<P>::target): New typedef.
(mln::line_graph_psite<P>::dim)
(mln::line_graph_psite<P>::coord)
(mln::line_graph_psite<P>::point)
(mln::line_graph_psite<P>::dpoint)
(mln::line_graph_psite<P>::mesh):
Remove typedefs.
(mln::line_graph_psite<P>::line_graph_psite(const self_&))
(mln::line_graph_psite<P>::self_& operator=)
(mln::line_graph_psite<P>::to_psite)
(mln::line_graph_psite<P>::to_point)
(mln::line_graph_psite<P>::operator point)
(mln::line_graph_psite<P>::operator[])
(mln::line_graph_psite<P>::plg):
Remove methods.
(mln::line_graph_psite<P>::invalidate)
(mln::line_graph_psite<P>::site_set)
(mln::line_graph_psite<P>::target_)
(mln::line_graph_psite<P>::change_target)
(mln::line_graph_psite<P>::subj_)
(mln::line_graph_psite<P>::update_)
(mln::line_graph_psite<P>::change_edge_id)
(mln::line_graph_psite<P>::inc_edge_id)
(mln::line_graph_psite<P>::dec_edge_id):
New methods.
(mln::line_graph_psite<P>::id): Rename as...
(mln::line_graph_psite<P>::edge_id): ...this.
(mln::line_graph_psite<P>::plg_): Change type to `const target*'.
(mln::line_graph_psite<P>::p_): Change type to site_pair<P>.
(operator!=(const line_graph_psite<P>&, const line_graph_psite<P>&)):
New operator.
---
milena/ChangeLog | 50 ++++++
milena/mln/core/image/line_graph_psite.hh | 263 ++++++++++++++++++-----------
2 files changed, 212 insertions(+), 101 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 7d3f79a..ae13b3c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,55 @@
2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+ Update line graph psite.
+
+ * mln/core/image/line_graph_psite.hh
+ (mln::line_graph_psite<P>): Inherit from
+ mln::internal::pseudo_site_base_.
+ (mln::line_graph_psite<P>::line_graph_psite):
+ Adjust ctors.
+ (mln::line_graph_psite<P>::first)
+ (mln::line_graph_psite<P>::second)
+ (mln::line_graph_psite<P>::first_id)
+ (mln::line_graph_psite<P>::second_id):
+ Adjust methods.
+ (operator==(const line_graph_psite<P>&, const line_graph_psite<P>&))
+ (operator< (const line_graph_psite<P>&, const line_graph_psite<P>&)):
+ Adjust operators.
+ (mln::line_graph_psite<P>::super_): Adjust.
+ (mln::line_graph_psite<P>::target): New typedef.
+ (mln::line_graph_psite<P>::dim)
+ (mln::line_graph_psite<P>::coord)
+ (mln::line_graph_psite<P>::point)
+ (mln::line_graph_psite<P>::dpoint)
+ (mln::line_graph_psite<P>::mesh):
+ Remove typedefs.
+ (mln::line_graph_psite<P>::line_graph_psite(const self_&))
+ (mln::line_graph_psite<P>::self_& operator=)
+ (mln::line_graph_psite<P>::to_psite)
+ (mln::line_graph_psite<P>::to_point)
+ (mln::line_graph_psite<P>::operator point)
+ (mln::line_graph_psite<P>::operator[])
+ (mln::line_graph_psite<P>::plg):
+ Remove methods.
+ (mln::line_graph_psite<P>::invalidate)
+ (mln::line_graph_psite<P>::site_set)
+ (mln::line_graph_psite<P>::target_)
+ (mln::line_graph_psite<P>::change_target)
+ (mln::line_graph_psite<P>::subj_)
+ (mln::line_graph_psite<P>::update_)
+ (mln::line_graph_psite<P>::change_edge_id)
+ (mln::line_graph_psite<P>::inc_edge_id)
+ (mln::line_graph_psite<P>::dec_edge_id):
+ New methods.
+ (mln::line_graph_psite<P>::id): Rename as...
+ (mln::line_graph_psite<P>::edge_id): ...this.
+ (mln::line_graph_psite<P>::plg_): Change type to `const target*'.
+ (mln::line_graph_psite<P>::p_): Change type to site_pair<P>.
+ (operator!=(const line_graph_psite<P>&, const line_graph_psite<P>&)):
+ New operator.
+
+2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+
Create an util::ordpair_-based container usable as a site.
* mln/util/site_pair.hh: New.
diff --git a/milena/mln/core/image/line_graph_psite.hh b/milena/mln/core/image/line_graph_psite.hh
index 8d65963..c3f51af 100644
--- a/milena/mln/core/image/line_graph_psite.hh
+++ b/milena/mln/core/image/line_graph_psite.hh
@@ -31,6 +31,9 @@
/// \file mln/core/image/line_graph_psite.hh
/// \brief Definition of a line graph-based point site.
+# include <mln/core/internal/pseudo_site_base.hh>
+
+# include <mln/util/site_pair.hh>
# include <mln/core/site_set/p_line_graph.hh>
/* FIXME: This class shares a lot with graph_psite. Factor as much as
@@ -42,76 +45,102 @@ namespace mln
// Fwd decl.
template <typename P> class p_line_graph;
+ template <typename P> class line_graph_psite;
+ // FIXME: Rename as line_graph_psite as p_line_graph_psite.
- /// \brief Point site associated to a mln::graph_image.
+ /// \brief Point site associated to a mln::line_graph_image.
+ ///
+ /// \arg \p P The type of the site.
template <typename P>
- class line_graph_psite : public Point_Site< line_graph_psite<P> >
+ class line_graph_psite
+ : public internal::pseudo_site_base_< const site_pair<P>&,
+ line_graph_psite<P> >
{
typedef line_graph_psite<P> self_;
- typedef Point_Site<self_> super_;
+ typedef internal::pseudo_site_base_< P, self_ > super_;
public:
- typedef P point;
- // FIXME: Dummy.
- typedef void mesh;
- enum { dim = point::dim };
- // FIXME: Dummy.
- typedef void dpoint;
- typedef mln_coord(point) coord;
+ // This associated type is important to know that this particular
+ // pseudo site knows the site set it refers to.
+ typedef p_line_graph<P> target;
/// Construction and assignment.
/// \{
line_graph_psite();
line_graph_psite(const p_line_graph<P>& plg, util::edge_id id);
- line_graph_psite(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
- /// Access to psite.
- const self_& to_psite() const;
+ /// Psite manipulators.
+ /// \{
+ /// Is this psite valid?
+ bool is_valid() const;
+ /// Invalidate this psite.
+ void invalidate();
+ /// \}
+
+ /// Site set manipulators.
+ /// \{
+ /// \brief Get the site set (shortcut for *target()).
+ /// \pre Member plg_ is non null.
+ const target& site_set() const;
+
+ /// Get a pointer to the target site_set.
+ const target* target_() const;
+ /// Set the target site_set.
+ void change_target(const target& new_target);
+ /// \}
- /// Access to point.
+ /// Proxy manipulators.
/// \{
- const point& to_point() const;
- operator point() const;
- coord operator[](unsigned id) const;
+ /// Return the site corresponding to this psite.
+ const site_pair<P>& subj_();
/// \}
- /// Return the mln::p_line_graph this point site belongs to.
- const p_line_graph<P>& plg() const;
+ /// Edge id manipulators.
+ //// \{
/// Return the edge id of this point site.
- util::edge_id id() const;
+ util::edge_id edge_id() const;
+ /// Set the edge id of this point site.
+ void change_edge_id(const util::edge_id& id);
+ /// Increment the edge id of this point site.
+ void inc_edge_id();
+ /// Increment the edge id of this point site.
+ void dec_edge_id();
+ /// \}
+ /// Accessors.
+ /// \{
/// Return the first associated vertex.
P first() const;
/// Return the second associated vertex.
P second() const;
/// Return the id of the first associated vertex.
+ // FIXME: Rename as first_vertex_id.
util::vertex_id first_id() const;
/// Return the id of the second associated vertex.
+ // FIXME: Rename as second_vertex_id.
util::vertex_id second_id() const;
+ /// \}
- /// Is this psite valid?
- bool is_valid() const;
+ private:
+ /// Site-related members.
+ /// \{
+ /// Update the site corresponding to this psite.
+ void update_();
+ // The site corresponding to this psite.
+ site_pair<P> p_;
+ /// \}
private:
+ /// Graph-related members.
+ /// \{
/// The p_line_graph this point site belongs to.
- const p_line_graph<P>* plg_;
+ const target* plg_;
/// The id of the edge this psite is pointing towards.
util::edge_id id_;
- /** \brief The point associated to this psite.
-
- Contrary to mln::graph_psite, this information is actually
- stored in the mln::line_graph_psite. In mln::graph_psite, the
- point is retrieved from the data associated with the
- corresponding vertex in the graph. We cannot do this here,
- since points associated to edges are computed on the fly
- (storing them in the graph could be possible, but too costly
- in space). */
- // FIXME: Actually, this is a dummy value!
- point p_;
+ /// \}
};
@@ -128,6 +157,14 @@ namespace mln
bool
operator==(const line_graph_psite<P>& lhs, const line_graph_psite<P>& rhs);
+ /// \brief Is \a lhs not equal to \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::p_line_graph.
+ template <typename P>
+ bool
+ operator!=(const line_graph_psite<P>& lhs, const line_graph_psite<P>& rhs);
+
/// \brief Is \a lhs ``less'' than \a rhs?
///
/// This comparison is required by algorithms sorting psites.
@@ -140,31 +177,19 @@ namespace mln
/// \}
- /* FIXME: This hand-made delegation is painful. We should rely on
- the general mechanism provided by Point_Site. But then again, we
- need to refine/adjust the interface of Point_Site w.r.t. the
- mandatory conversions to points. */
template <typename P>
inline
std::ostream&
operator<<(std::ostream& ostr, const line_graph_psite<P>& p);
-# ifndef MLN_INCLUDE_ONLY
- /* Careful, the current interface of line_graph_psite allows the
- construction of ill-formed psites (i.e., whose edge is is beyond
- bounds). Actually, p_line_graph_piters *do* create ill-formed
- psites at their initialization. */
+# ifndef MLN_INCLUDE_ONLY
template <typename P>
inline
line_graph_psite<P>::line_graph_psite()
- // Dummy initializations.
- : super_(),
- plg_(0),
- id_(-1),
- p_()
+ : plg_(0)
{
}
@@ -172,94 +197,109 @@ namespace mln
inline
line_graph_psite<P>::line_graph_psite(const p_line_graph<P>& plg,
util::edge_id id)
- : super_(),
- plg_(&plg),
- id_(id),
- p_()
+ : plg_(&plg),
+ id_(id)
{
+ update_();
}
template <typename P>
inline
- line_graph_psite<P>::line_graph_psite(const line_graph_psite<P>& rhs)
- : super_(rhs),
- plg_(rhs.plg_),
- id_(rhs.id_),
- p_()
+ const p_line_graph<P>&
+ line_graph_psite<P>::site_set() const
{
+ mln_precondition(plg_);
+ return *plg_;
}
template <typename P>
inline
- line_graph_psite<P>&
- line_graph_psite<P>::operator=(const line_graph_psite<P>& rhs)
+ const p_line_graph<P>*
+ line_graph_psite<P>::target_() const
{
- if (&rhs == this)
- return *this;
- plg_ = rhs.plg_;
- id_ = rhs.id_;
- return *this;
+ return plg_;
}
template <typename P>
inline
- bool
- line_graph_psite<P>::is_valid() const
+ void
+ line_graph_psite<P>::change_target(const p_line_graph<P>& new_target)
{
- return plg_ && id_ < plg_->gr_->nedges();
+ plg_ = & new_target;
+ invalidate();
}
template <typename P>
inline
- const line_graph_psite<P>&
- line_graph_psite<P>::to_psite() const
+ const site_pair<P>&
+ line_graph_psite<P>::subj_()
{
- return *this;
+ // FIXME: p_ is not properly updated yet; we shouldn't call this
+ // method yet.
+ abort();
+ return p_;
}
+
template <typename P>
inline
- const P&
- line_graph_psite<P>::to_point() const
+ bool
+ line_graph_psite<P>::is_valid() const
{
- // Dummy value.
- abort();
- return p_;
+ /* FIXME: Instead of `plg_->gr_->nedges()', we should have
+ something like `run_->has_edge_id(id_)' (see the implementation of
+ p_run_psite. */
+ return plg_ && id_ < plg_->gr_->nedges();
}
template <typename P>
inline
- line_graph_psite<P>::operator P() const
+ void
+ line_graph_psite<P>::invalidate()
{
- // Dummy value.
- abort();
- return p_;
+ /* FIXME: Instead of `plg_->gr_->nedges()', we should have
+ something like `run_->has_edge_id(id_)' (see the implementation of
+ p_run_psite. */
+ id_ = plg_->gr_->nedges();
}
+
template <typename P>
inline
- mln_coord(P)
- line_graph_psite<P>::operator[](unsigned i) const
+ util::edge_id
+ line_graph_psite<P>::edge_id() const
{
- mln_assertion(is_valid());
- return to_point()[i];
+ return id_;
}
template <typename P>
inline
- const p_line_graph<P>&
- line_graph_psite<P>::plg() const
+ void
+ line_graph_psite<P>::change_edge_id(const util::edge_id& id)
{
- mln_assertion(plg_);
- return *plg_;
+ id_ = id;
+ if (is_valid())
+ update_();
}
template <typename P>
inline
- util::edge_id
- line_graph_psite<P>::id() const
+ void
+ line_graph_psite<P>::inc_edge_id()
{
- return id_;
+ ++id_.to_equiv();
+ if (is_valid())
+ update_();
+ }
+
+ template <typename P>
+ inline
+ void
+ line_graph_psite<P>::dec_edge_id()
+ {
+ --id_.to_equiv();
+ if (is_valid())
+ update_();
}
template <typename P>
@@ -268,7 +308,8 @@ namespace mln
line_graph_psite<P>::first() const
{
mln_assertion(is_valid());
- return plg().gr_->vertex_data(first_id());
+ // FIXME: Too low-level.
+ return plg_->gr_->vertex_data(first_id());
}
template <typename P>
@@ -277,17 +318,18 @@ namespace mln
line_graph_psite<P>::second() const
{
mln_assertion(is_valid());
- return plg().gr_->vertex_data(second_id());
+ // FIXME: Too low-level.
+ return plg_->gr_->vertex_data(second_id());
}
-
template <typename P>
inline
util::vertex_id
line_graph_psite<P>::first_id() const
{
mln_assertion(is_valid());
- return plg().gr_->edge(id_).v1();
+ // FIXME: Too low-level.
+ return plg_->gr_->edge(id_).v1();
}
template <typename P>
@@ -296,7 +338,19 @@ namespace mln
line_graph_psite<P>::second_id() const
{
mln_assertion(is_valid());
- return plg().gr_->edge(id_).v2();
+ // FIXME: Too low-level.
+ return plg_->gr_->edge(id_).v2();
+ }
+
+
+ template <typename P>
+ inline
+ void
+ line_graph_psite<P>::update_()
+ {
+ mln_assertion(is_valid());
+ p_.pair_.first = first();
+ p_.pair_.second = second();
}
@@ -308,16 +362,24 @@ namespace mln
bool
operator==(const line_graph_psite<P>& lhs, const line_graph_psite<P>& rhs)
{
- mln_assertion(&lhs.plg() == &rhs.plg());
- return lhs.id() == rhs.id();
+ mln_assertion(lhs.target_() == rhs.target_());
+ return lhs.edge_id() == rhs.edge_id();
+ }
+
+ template <typename P>
+ bool
+ operator!=(const line_graph_psite<P>& lhs, const line_graph_psite<P>& rhs)
+ {
+ mln_assertion(lhs.target_() == rhs.target_());
+ return lhs.edge_id() != rhs.edge_id();
}
template <typename P>
bool
operator< (const line_graph_psite<P>& lhs, const line_graph_psite<P>& rhs)
{
- mln_assertion(&lhs.plg() == &rhs.plg());
- return lhs.id() < rhs.id();
+ mln_assertion(lhs.target_() == rhs.target_());
+ return lhs.edge_id() < rhs.edge_id();
}
@@ -335,7 +397,6 @@ namespace mln
# endif // ! MLN_INCLUDE_ONLY
-
} // end of mln
#endif // MLN_CORE_IMAGE_LINE_GRAPH_PSITE_HH
--
1.6.0.1
1
0
17 Sep '08
* mln/util/site_pair.hh: New.
---
milena/ChangeLog | 6 +++
milena/mln/util/site_pair.hh | 100 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 106 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/util/site_pair.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2a8833e..7d3f79a 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+ Create an util::ordpair_-based container usable as a site.
+
+ * mln/util/site_pair.hh: New.
+
+2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+
Update util::ordpair_.
* mln/util/ordpair.hh
diff --git a/milena/mln/util/site_pair.hh b/milena/mln/util/site_pair.hh
new file mode 100644
index 0000000..76ab3ab
--- /dev/null
+++ b/milena/mln/util/site_pair.hh
@@ -0,0 +1,100 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_UTIL_SITE_PAIR_HH
+# define MLN_UTIL_SITE_PAIR_HH
+
+# include <mln/util/ordpair.hh>
+
+/// \file mln/util/site_pair.hh
+/// \brief Definition of a site pair type.
+
+namespace mln
+{
+ /* FIXME: The class mln::internal::image_base requires its site
+ types to have a `coord' typedef, but util::ordpair_ has none.
+ Hence this small workaround. Remove as soon as image_base is
+ refurbished. */
+ template <typename P>
+ struct site_pair : public mln::Object< site_pair<P> >
+ {
+ site_pair();
+ site_pair(const P& first, const P& second);
+ typedef mln_coord(P) coord;
+ util::ordpair_<P> pair_;
+ };
+
+ /* FIXME: The proxy mechanism requires these operators; why? It
+ seems its static assertions do not check the right guy. IMHO
+ (Roland's), it should look for line_graph_psite's operators,
+ not site_pair's. */
+ template <typename P>
+ bool operator==(const site_pair<P>& lhs, const site_pair<P>& rhs);
+
+ template <typename P>
+ bool operator< (const site_pair<P>& lhs, const site_pair<P>& rhs);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ site_pair<P>::site_pair()
+ : pair_(P(), P())
+ {
+ }
+
+ template <typename P>
+ site_pair<P>::site_pair(const P& first, const P& second)
+ : pair_(first, second)
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ operator==(const site_pair<P>& lhs, const site_pair<P>& rhs)
+ {
+ abort();
+ return lhs.pair_ == rhs.pair_;
+ }
+
+ template <typename P>
+ inline
+ bool
+ operator< (const site_pair<P>& lhs, const site_pair<P>& rhs)
+ {
+ abort();
+ return lhs.pair_ < rhs.pair_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of mln
+
+
+#endif // ! MLN_UTIL_SITE_PAIR_HH
--
1.6.0.1
1
0
* mln/util/ordpair.hh
(mln::util::ordpair_<T>::ordpair_)
(operator< (const ordpair_<T>&, const ordpair_<T>&))
(operator<=(const ordpair_<T>&, const ordpair_<T>&)):
Replace the use of operator < (resp. operator <=) by
util::ord_strict (reps. util::ord_weak).
---
milena/ChangeLog | 11 +++++++++++
milena/mln/util/ordpair.hh | 25 ++++++++++++++-----------
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e4d7a70..2a8833e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+ Update util::ordpair_.
+
+ * mln/util/ordpair.hh
+ (mln::util::ordpair_<T>::ordpair_)
+ (operator< (const ordpair_<T>&, const ordpair_<T>&))
+ (operator<=(const ordpair_<T>&, const ordpair_<T>&)):
+ Replace the use of operator < (resp. operator <=) by
+ util::ord_strict (reps. util::ord_weak).
+
+2008-09-17 Roland Levillain <roland(a)lrde.epita.fr>
+
Update util::gen_id.
* mln/util/internal/graph_base.hh (mln::util::gen_id<Tag, Equiv>):
diff --git a/milena/mln/util/ordpair.hh b/milena/mln/util/ordpair.hh
index 9da142f..3798c80 100644
--- a/milena/mln/util/ordpair.hh
+++ b/milena/mln/util/ordpair.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 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
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/object.hh>
+# include <mln/util/ord.hh>
namespace mln
@@ -48,6 +49,7 @@ namespace mln
* ordering.
*
*/
+ // FIXME: Rename as ordpair.
template <typename T>
struct ordpair_ : public mln::Object< ordpair_<T> >
{
@@ -71,6 +73,7 @@ namespace mln
std::ostream& operator<<(std::ostream& ostr, const ordpair_<T>& op);
+ // FIXME: Rename as make::ordpair.
/// Routine to construct a ordpair on the fly.
template <typename T>
ordpair_<T> ordpair(const T& t1, const T& t2);
@@ -82,17 +85,17 @@ namespace mln
inline
ordpair_<T>::ordpair_(const T& t1, const T& t2)
{
- if (t1 > t2)
+ if (util::ord_strict(t1, t2))
{
- first = t2;
- second = t1;
+ first = t1;
+ second = t2;
}
else
{
- first = t1;
- second = t2;
+ first = t2;
+ second = t1;
}
- mln_postcondition(first <= second);
+ mln_postcondition(util::ord_weak(first, second));
}
template <typename T>
@@ -107,8 +110,8 @@ namespace mln
bool operator< (const ordpair_<T>& lhs, const ordpair_<T>& rhs)
{
return
- lhs.first < rhs.first ||
- (lhs.first == rhs.first && lhs.second < rhs.second);
+ util::ord_strict(lhs.first, rhs.first) ||
+ (lhs.first == rhs.first && util::ord_strict(lhs.second, rhs.second));
}
template <typename T>
@@ -116,8 +119,8 @@ namespace mln
bool operator<=(const ordpair_<T>& lhs, const ordpair_<T>& rhs)
{
return
- lhs.first < rhs.first ||
- (lhs.first == rhs.first && lhs.second <= rhs.second);
+ util::ord_strict(lhs.first, rhs.first) ||
+ (lhs.first == rhs.first && util::ord_weak(lhs.second, rhs.second));
}
--
1.6.0.1
1
0