olena-2.0-118-g9536c4c Small fixes.

* mln/value/interval.hh, * tests/value/interval.cc: Rename nvalues() to nelements(). * mln/value/intsub.hh: Add a missing include. --- milena/ChangeLog | 9 +++++++++ milena/mln/value/interval.hh | 25 +++++++++++++++---------- milena/mln/value/intsub.hh | 1 + milena/tests/value/interval.cc | 4 ++-- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 11c4862..2bf24a9 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,14 @@ 2012-10-22 Guillaume Lazzara <z@lrde.epita.fr> + Small fixes. + + * mln/value/interval.hh, + * tests/value/interval.cc: Rename nvalues() to nelements(). + + * mln/value/intsub.hh: Add a missing include. + +2012-10-22 Guillaume Lazzara <z@lrde.epita.fr> + Add aliases for value::intsub. * mln/value/intsub.hh diff --git a/milena/mln/value/interval.hh b/milena/mln/value/interval.hh index a7cafc7..fbc9da1 100644 --- a/milena/mln/value/interval.hh +++ b/milena/mln/value/interval.hh @@ -43,6 +43,10 @@ namespace mln namespace value { + // Forward declaration. + template <unsigned n> class intsub; + template <unsigned n> class int_u; + /// \brief Interval of values. template <typename T> class interval : public value::Interval<interval<T> > @@ -70,7 +74,7 @@ namespace mln unsigned index_of(const T& v) const; /// Return the number of values in this interval. - unsigned nvalues() const; + unsigned nelements() const; /// Return True if this interval contains only one value. bool is_degenerated() const; @@ -88,7 +92,7 @@ namespace mln private: T first_; T last_; - unsigned nvalues_; + unsigned nelements_; }; // comparison @@ -184,6 +188,7 @@ namespace mln std::ostream& operator<<(std::ostream& ostr, const interval<T>& i); + } // end of namespace mln::value } // end of namespace mln @@ -226,7 +231,7 @@ namespace mln first_ = single; last_ = single; - nvalues_ = 1; + nelements_ = 1; } @@ -237,9 +242,9 @@ namespace mln first_ = first; last_ = last; - nvalues_ = 0; + nelements_ = 0; for (T v = first_; v <= last_; value::inc(v)) - ++nvalues_; + ++nelements_; } template <typename T> @@ -269,7 +274,7 @@ namespace mln T interval<T>::ith_element(unsigned i) const { - mln_precondition(i < nvalues()); + mln_precondition(i < nelements()); return first_ + i * iota<T>::value(); } @@ -283,9 +288,9 @@ namespace mln template <typename T> unsigned - interval<T>::nvalues() const + interval<T>::nelements() const { - return nvalues_; + return nelements_; } template <typename T> @@ -315,11 +320,11 @@ namespace mln { if (is_degenerated()) abort(); - mln_precondition(nvalues_ > 2); + mln_precondition(nelements_ > 2); first += iota<T>::value(); last_ -= iota<T>::value(); - nvalues_ -= 2; + nelements_ -= 2; } diff --git a/milena/mln/value/intsub.hh b/milena/mln/value/intsub.hh index be37291..609bd12 100644 --- a/milena/mln/value/intsub.hh +++ b/milena/mln/value/intsub.hh @@ -33,6 +33,7 @@ # include <cstdlib> # include <iostream> # include <sstream> +# include <vector> # include <algorithm> # include <mln/core/routine/ops.hh> # include <mln/value/ops.hh> diff --git a/milena/tests/value/interval.cc b/milena/tests/value/interval.cc index 2f57c4c..fe5a183 100644 --- a/milena/tests/value/interval.cc +++ b/milena/tests/value/interval.cc @@ -47,7 +47,7 @@ int main() R r(0, 0); assert(r.is_degenerated()); assert(r.length() == 0); - assert(r.nvalues() == 1); + assert(r.nelements() == 1); } { @@ -64,7 +64,7 @@ int main() R r(1, 5); assert(!r.is_degenerated()); assert(r.length() == 4); - assert(r.nvalues() == 9); + assert(r.nelements() == 9); int ref_i = 2; for (intsub<2> v = r.first(); v <= r.last(); inc(v)) -- 1.7.2.5
participants (1)
-
Guillaume Lazzara