https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix bug in p_array.
This bug arises when we write:
for_all(p) // in a p_array
for_all(n) // around p
here n has a direct access to the p_array::psite::p_
which needs to be updated when p moves.
unfortunatly there was a (too) lazy update.
* mln/core/site_set/p_array.hh (update_): New.
(subj_, start_, next_): Use update_.
p_array.hh | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
Index: mln/core/site_set/p_array.hh
--- mln/core/site_set/p_array.hh (revision 3017)
+++ mln/core/site_set/p_array.hh (working copy)
@@ -208,6 +208,8 @@
operator util::index() const;
+ void update_() const;
+
private:
const S* s_;
@@ -560,10 +562,17 @@
const mln_element(S)&
p_indexed_psite<S>::subj_()
{
+ update_(); // In case of...
+ return p_;
+ }
+
+ template <typename S>
+ inline
+ void
+ p_indexed_psite<S>::update_() const
+ {
if (is_valid())
- // Lazy update.
p_ = (*s_)[i_];
- return p_;
}
template <typename S>
@@ -612,6 +621,7 @@
p_indexed_fwd_piter<S>::start_()
{
p_.change_index(0);
+ p_.update_();
}
template <typename S>
@@ -620,6 +630,7 @@
p_indexed_fwd_piter<S>::next_()
{
p_.inc_index();
+ p_.update_();
}
template <typename S>
@@ -669,6 +680,7 @@
p_indexed_bkd_piter<S>::start_()
{
p_.change_index(s_->nsites() - 1);
+ p_.update_();
}
template <typename S>
@@ -677,6 +689,7 @@
p_indexed_bkd_piter<S>::next_()
{
p_.dec_index();
+ p_.update_();
}
template <typename S>