* mln/topo/n_face_iter.hh
(mln::n_face_fwd_iter<D>::invalidate_face_id_)
(mln::n_face_bkd_iter<D>::invalidate_face_id_):
New methods.
(mln::n_face_fwd_iter<D>::next_)
(mln::n_face_bkd_iter<D>::next_):
Use it here, instead of invalidate().
(mln::n_face_fwd_iter<D>::start_): Don't set n_.
---
milena/ChangeLog | 13 +++++++++++++
milena/mln/topo/n_face_iter.hh | 35 ++++++++++++++++++++++++++++++++---
2 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2cb56bd..2da6062 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2008-10-24 Roland Levillain <roland(a)lrde.epita.fr>
+ Fix a bug in iterators on n-faces.
+
+ * mln/topo/n_face_iter.hh
+ (mln::n_face_fwd_iter<D>::invalidate_face_id_)
+ (mln::n_face_bkd_iter<D>::invalidate_face_id_):
+ New methods.
+ (mln::n_face_fwd_iter<D>::next_)
+ (mln::n_face_bkd_iter<D>::next_):
+ Use it here, instead of invalidate().
+ (mln::n_face_fwd_iter<D>::start_): Don't set n_.
+
+2008-10-24 Roland Levillain <roland(a)lrde.epita.fr>
+
Add operator== on mln::util::multi_site to please mln::p_queue_fast.
* mln/util/multi_site.hh
diff --git a/milena/mln/topo/n_face_iter.hh b/milena/mln/topo/n_face_iter.hh
index 4b658bb..f12c511 100644
--- a/milena/mln/topo/n_face_iter.hh
+++ b/milena/mln/topo/n_face_iter.hh
@@ -97,6 +97,10 @@ namespace mln
/// \}
private:
+ /// Partially invalidate the iterator (don't alter its dimension).
+ void invalidate_face_id_();
+
+ private:
using super_::f_;
};
@@ -147,6 +151,10 @@ namespace mln
/// \}
private:
+ /// Partially invalidate the iterator (don't alter its dimension).
+ void invalidate_face_id_();
+
+ private:
using super_::f_;
};
@@ -194,12 +202,23 @@ namespace mln
if (f_.face_id() + 1 < f_.cplx().nfaces(n()))
f_.inc_face_id();
else
- invalidate();
+ /* Don't invalidate the whole face if we have reached the
+ last face of the dimension---this would lose the
+ dimension. Instead, invalidate the face_id only. */
+ invalidate_face_id_();
}
}
template <unsigned D>
inline
+ void
+ n_face_fwd_iter<D>::invalidate_face_id_()
+ {
+ f_.set_face_id(f_.cplx().nfaces(n()));
+ }
+
+ template <unsigned D>
+ inline
unsigned
n_face_fwd_iter<D>::n() const
{
@@ -243,7 +262,6 @@ namespace mln
void
n_face_bkd_iter<D>::start()
{
- f_.set_n(n());
f_.set_face_id(f_.cplx().nfaces(n()) - 1);
}
@@ -257,12 +275,23 @@ namespace mln
if (f_.face_id() > 0)
f_.dec_face_id();
else
- invalidate();
+ /* Don't invalidate the whole face if we have reached the
+ last face of the dimension---this would lose the
+ dimension. Instead, invalidate the face_id only. */
+ invalidate_face_id_();
}
}
template <unsigned D>
inline
+ void
+ n_face_bkd_iter<D>::invalidate_face_id_()
+ {
+ f_.set_face_id(f_.cplx().nfaces(n()));
+ }
+
+ template <unsigned D>
+ inline
unsigned
n_face_bkd_iter<D>::n() const
{
--
1.5.6.5
Show replies by date