* mln/core/complex_iter.hh, mln/core/faces_iter.hh:
Fix and supplement documentation.
Add missing postconditions.
(mln::complex_fwd_iter_<D>::complex_dim)
(mln::complex_bkd_iter_<D>::complex_dim):
Remove constants.
(mln::complex_fwd_iter_<D>::complex_fwd_iter_(const self_&))
(mln::complex_bkd_iter_<D>::complex_bkd_iter_(const self_&))
(mln::faces_fwd_iter_<N, D>::faces_fwd_iter_(const self_&))
(mln::faces_bkd_iter_<N, D>::faces_bkd_iter_(const self_&)):
Remove copy ctors.
(mln::complex_fwd_iter_<D>::operator=(const self_&))
(mln::complex_bkd_iter_<D>::operator=(const self_&))
(mln::faces_fwd_iter_<N, D>::operator=(const self_&))
(mln::faces_bkd_iter_<N, D>::operator=(const self_&)):
Remove assignment operators.
(mln::complex_fwd_iter_<D>::set_cplx)
(mln::complex_bkd_iter_<D>::set_cplx)
(mln::faces_fwd_iter_<N, D>::set_cplx)
(mln::faces_bkd_iter_<N, D>::set_cplx):
Remove accessors.
---
milena/ChangeLog | 26 +++++++++++
milena/mln/core/complex_iter.hh | 90 ++++----------------------------------
milena/mln/core/faces_iter.hh | 82 +++--------------------------------
3 files changed, 44 insertions(+), 154 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 005bbdc..72e25d3 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -41,6 +41,32 @@
2008-09-24 Roland Levillain <roland(a)lrde.epita.fr>
+ Simplify iterators on complexes.
+
+ * mln/core/complex_iter.hh, mln/core/faces_iter.hh:
+ Fix and supplement documentation.
+ Add missing postconditions.
+ (mln::complex_fwd_iter_<D>::complex_dim)
+ (mln::complex_bkd_iter_<D>::complex_dim):
+ Remove constants.
+ (mln::complex_fwd_iter_<D>::complex_fwd_iter_(const self_&))
+ (mln::complex_bkd_iter_<D>::complex_bkd_iter_(const self_&))
+ (mln::faces_fwd_iter_<N, D>::faces_fwd_iter_(const self_&))
+ (mln::faces_bkd_iter_<N, D>::faces_bkd_iter_(const self_&)):
+ Remove copy ctors.
+ (mln::complex_fwd_iter_<D>::operator=(const self_&))
+ (mln::complex_bkd_iter_<D>::operator=(const self_&))
+ (mln::faces_fwd_iter_<N, D>::operator=(const self_&))
+ (mln::faces_bkd_iter_<N, D>::operator=(const self_&)):
+ Remove assignment operators.
+ (mln::complex_fwd_iter_<D>::set_cplx)
+ (mln::complex_bkd_iter_<D>::set_cplx)
+ (mln::faces_fwd_iter_<N, D>::set_cplx)
+ (mln::faces_bkd_iter_<N, D>::set_cplx):
+ Remove accessors.
+
+2008-09-24 Roland Levillain <roland(a)lrde.epita.fr>
+
Simplify mln::internal::complex_iter_base_.
* mln/core/internal/complex_iter_base.hh:
diff --git a/milena/mln/core/complex_iter.hh b/milena/mln/core/complex_iter.hh
index 1e60fe0..2a486be 100644
--- a/milena/mln/core/complex_iter.hh
+++ b/milena/mln/core/complex_iter.hh
@@ -57,9 +57,6 @@ namespace mln
public:
/// Type of associated face.
typedef any_face_handle<D> face;
- // FIXME: Rename as dim?
- /// Dimension of the complex.
- static const unsigned complex_dim = D;
private:
typedef complex_fwd_iter_<D> self_;
@@ -73,18 +70,12 @@ namespace mln
/// Construction and assignment.
/// \{
complex_fwd_iter_();
- // FIXME: See above (internal::complex_iter_base_'s default ctor).
+ // FIXME: See comment in internal::complex_iter_base_'s default ctor
complex_fwd_iter_(complex<D>& c);
- complex_fwd_iter_(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
/// Manipulation.
/// \{
- /// Change the target complex.
- // FIXME: Same comment as the ctor above.
- void set_cplx(complex<D>& c);
-
/// Test if the iterator is valid.
void start();
/// Go to the next point.
@@ -111,9 +102,6 @@ namespace mln
public:
/// Type of associated face.
typedef any_face_handle<D> face;
- // FIXME: Rename as dim?
- /// Dimension of the complex.
- static const unsigned complex_dim = D;
private:
typedef complex_bkd_iter_<D> self_;
@@ -127,18 +115,12 @@ namespace mln
/// Construction and assignment.
/// \{
complex_bkd_iter_();
- // FIXME: See above (internal::complex_iter_base_'s default ctor).
+ // FIXME: See comment in internal::complex_iter_base_'s default ctor
complex_bkd_iter_(complex<D>& c);
- complex_bkd_iter_(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
/// Manipulation.
/// \{
- /// Change the target complex.
- // FIXME: Same comment as the ctor above.
- void set_cplx(complex<D>& c);
-
/// Start an iteration.
void start();
/// Go to the next point.
@@ -175,34 +157,6 @@ namespace mln
template <unsigned D>
inline
- complex_fwd_iter_<D>::complex_fwd_iter_(const complex_fwd_iter_<D>&
rhs)
- : super_(rhs)
- {
- }
-
- template <unsigned D>
- inline
- complex_fwd_iter_<D>&
- complex_fwd_iter_<D>::operator=(const complex_fwd_iter_<D>& rhs)
- {
- if (&rhs == this)
- return *this;
- super_::operator=(rhs);
- return *this;
- }
-
- template <unsigned D>
- inline
- void
- complex_fwd_iter_<D>::set_cplx(complex<D>& c)
- {
- face_.set_cplx(c);
- // Invalidate face_.
- invalidate();
- }
-
- template <unsigned D>
- inline
void
complex_fwd_iter_<D>::start()
{
@@ -221,12 +175,14 @@ namespace mln
unsigned face_id = face_.face_id();
if (face_id + 1 < face_.cplx().nfaces(n))
- /* FIXME: Provide accessor any_face_handle::n() returning
+ /* FIXME: Provide accessor any_face_handle::face_id() returning
a mutable reference? This way, we could just write
++face_.face_id();
- instead of the following. */
+ instead of the following.
+
+ Or add {inc,add}_face_id() services. */
face_.set_face_id(face_id + 1);
else
// Start to iterate on the faces of the next dimension if
@@ -265,34 +221,6 @@ namespace mln
template <unsigned D>
inline
- complex_bkd_iter_<D>::complex_bkd_iter_(const complex_bkd_iter_<D>&
rhs)
- : super_(rhs)
- {
- }
-
- template <unsigned D>
- inline
- complex_bkd_iter_<D>&
- complex_bkd_iter_<D>::operator=(const complex_bkd_iter_<D>& rhs)
- {
- if (&rhs == this)
- return *this;
- super_::operator=(rhs);
- return *this;
- }
-
- template <unsigned D>
- inline
- void
- complex_bkd_iter_<D>::set_cplx(complex<D>& c)
- {
- face_.set_cplx(c);
- // Invalidate face_.
- invalidate();
- }
-
- template <unsigned D>
- inline
void
complex_bkd_iter_<D>::start()
{
@@ -311,12 +239,14 @@ namespace mln
unsigned face_id = face_.face_id();
if (face_id > 0)
- /* FIXME: Provide accessor any_face_handle::n() returning
+ /* FIXME: Provide accessor any_face_handle::face_id() returning
a mutable reference? This way, we could just write
++face_.face_id();
- instead of the following. */
+ instead of the following.
+
+ Or add {inc,add}_face_id() services. */
face_.set_face_id(face_id - 1);
else
// Start to iterate on the faces of the previous dimension
diff --git a/milena/mln/core/faces_iter.hh b/milena/mln/core/faces_iter.hh
index 522f2ab..6194deb 100644
--- a/milena/mln/core/faces_iter.hh
+++ b/milena/mln/core/faces_iter.hh
@@ -51,6 +51,7 @@ namespace mln
faces_fwd_iter_<N, D> >
{
public:
+ /// Type of associated face.
typedef face_handle<N, D> face;
private:
@@ -65,18 +66,12 @@ namespace mln
/// Construction and assignment.
/// \{
faces_fwd_iter_();
- // FIXME: See above (internal::complex_iter_base_'s default ctor).
+ // FIXME: See comment in internal::complex_iter_base_'s default ctor
faces_fwd_iter_(complex<D>& c);
- faces_fwd_iter_(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
/// Manipulation.
/// \{
- /// Change the target complex.
- // FIXME: Same comment as the ctor above.
- void set_cplx(complex<D>& c);
-
/// Test if the iterator is valid.
void start();
/// Go to the next point.
@@ -102,6 +97,7 @@ namespace mln
faces_bkd_iter_<N, D> >
{
public:
+ /// Type of associated face.
typedef face_handle<N, D> face;
private:
@@ -116,18 +112,12 @@ namespace mln
/// Construction and assignment.
/// \{
faces_bkd_iter_();
- // FIXME: See above (internal::complex_iter_base_'s default ctor).
+ // FIXME: See comment in internal::complex_iter_base_'s default ctor
faces_bkd_iter_(complex<D>& c);
- faces_bkd_iter_(const self_& rhs);
- self_& operator= (const self_& rhs);
/// \}
/// Manipulation.
/// \{
- /// Change the target complex.
- // FIXME: Same comment as the ctor above.
- void set_cplx(complex<D>& c);
-
/// Start an iteration.
void start();
/// Go to the next point.
@@ -153,6 +143,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
+ mln_postcondition(!is_valid());
}
template <unsigned N, unsigned D>
@@ -162,36 +153,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
- }
-
- template <unsigned N, unsigned D>
- inline
- faces_fwd_iter_<N, D>::faces_fwd_iter_(const faces_fwd_iter_<N, D>&
rhs)
- : super_(rhs)
- {
- // Ensure N is compatible with D.
- metal::bool_< N <= D >::check();
- }
-
- template <unsigned N, unsigned D>
- inline
- void
- faces_fwd_iter_<N, D>::set_cplx(complex<D>& c)
- {
- face_.set_cplx(c);
- // Invalidate face_.
- invalidate();
- }
-
- template <unsigned N, unsigned D>
- inline
- faces_fwd_iter_<N, D>&
- faces_fwd_iter_<N, D>::operator=(const faces_fwd_iter_<N, D>& rhs)
- {
- if (&rhs == this)
- return *this;
- super_::operator=(rhs);
- return *this;
+ mln_postcondition(!is_valid());
}
template <unsigned N, unsigned D>
@@ -235,6 +197,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
+ mln_postcondition(!is_valid());
}
template <unsigned N, unsigned D>
@@ -244,36 +207,7 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
- }
-
- template <unsigned N, unsigned D>
- inline
- faces_bkd_iter_<N, D>::faces_bkd_iter_(const faces_bkd_iter_<N, D>&
rhs)
- : super_(rhs)
- {
- // Ensure N is compatible with D.
- metal::bool_< N <= D >::check();
- }
-
- template <unsigned N, unsigned D>
- inline
- void
- faces_bkd_iter_<N, D>::set_cplx(complex<D>& c)
- {
- face_.set_cplx(c);
- // Invalidate face_.
- invalidate();
- }
-
- template <unsigned N, unsigned D>
- inline
- faces_bkd_iter_<N, D>&
- faces_bkd_iter_<N, D>::operator=(const faces_bkd_iter_<N, D>& rhs)
- {
- if (&rhs == this)
- return *this;
- super_::operator=(rhs);
- return *this;
+ mln_postcondition(!is_valid());
}
template <unsigned N, unsigned D>
--
1.6.0.1